Mobile app version of vmapp.org
Login or Join
Ann8826881

: How to make parameters look more attractive I'm making a blog site and instead of the users blogs being called /blog?display=username I would like it to just be a sub domain such as mysite.com/username

@Ann8826881

Posted in: #Apache #ModRewrite

I'm making a blog site and instead of the users blogs being called /blog?display=username I would like it to just be a sub domain such as mysite.com/username

How would I be able to make the first URL look like the second URL?

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Ann8826881

3 Comments

Sorted by latest first Latest Oldest Best

 

@Sent6035632

You can use the PATH_INFO variable. More here: httpd.apache.org/docs/2.0/mod/core.html
Previous answer (using Request.PathInfo) was tarted at asp.net -- thanks for pointing that out.

10% popularity Vote Up Vote Down


 

@Lee4591628

You are probably looking for mod_rewrite. It's easy, just put this in your .htaccess file.

RewriteEngine On
RewriteRule ^(.*)$ /blog?display=

10% popularity Vote Up Vote Down


 

@Hamaas447

Place this in your .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /blog?display= [L]


This will redirect each URL which do not corresponds to an existing file (!-f) or existing directory (!-d) to the corresponding blog?... URL. [L] makes the rewriting stop here (in case you have more rules). See the mod_rewrite Guide for details.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme