View Full Version : Htaccess - rewrite url with arguments to dir structure

04-01-2008, 11:55 AM

I would like to rewrite (engine is on) some url with arguments to a directory structure like:

http://www.mysite.com/?brand=sony to http://www.mysite.com/sony/

Thanks for your help,

04-01-2008, 12:25 PM
Try this!

RewriteCond %{QUERY_STRING} brand=sony
RewriteRule ^(.*)$ http://www.mysite.com/sony/ [QSA,L]

04-01-2008, 01:15 PM
Thanks Pramit,

Unfortunately, I got a 500 server error with it....

Is it also possible to have different redirects, e.g.

?brand=sony to /sony/

?brand=philips to /philips/

and so on


04-02-2008, 03:29 AM
Yes it is, try something like this.

RewriteEngine on
RewriteRule ^([0-9a-zA-Z_]+)*/?$ /index.php?brand=$1 [L]

This should rewrite a url like yoursite.com/?brand=sony to yoursite.com/sony/. In the code index.php is the page you would like to direct it to (I assumed index) and brand is the name of the $_GET variable you are using.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum