Aug 02 2008

Correct .htaccess structure

Published by Gaurav Mishra at 9:39 pm under programming

Usually we all get very greedy while making our url structure using .htaccess

For example, This will not work as you think

RewriteRule ^(.*)/$ category/categories.php?cat=$1 [L,QSA]
RewriteRule ^(.*)/(.*)/$ category/categories.php?cat=$1&name=$2 [L,QSA]

This will not work as after first rewrite will write , the current url structure will change to www.mydomain.com/<something>, Which will result to the last rewrite rule to be implemented after current url structure , i.e www.mydomain.com/<something>/ , Which is different from origianl structure www.mydomain.com. This can also result in loss of images as they are on relative path

RewriteRule ^([^/]+)/$ category/categories.php?region=$1 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/$ category/categories.php?cat=$1&name=$2 [L,QSA]

My two cents

Trackback URI | Comments RSS

Leave a Reply

FireStats icon Powered by FireStats