...

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



Jerome
04-01-2008, 10:55 AM
Hi,

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,

Pramit
04-01-2008, 11:25 AM
Try this!

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

Jerome
04-01-2008, 12: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

Thanks,

zfred09
04-02-2008, 02: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