Question : Please check my mod_rewrite

I just want to make sure this is correct:

RewriteEngine on
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
RewriteRule index/(.*)/(.*)/$ /index.php?$1=$2
RewriteRule cities/(.*)/(.*)/$ /cities.php?$1=$2
RewriteRule towns/(.*)/(.*)/$ /towns.php?$1=$2
RewriteRule profile/(.*)/(.*)/$ /profile.php?$1=$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ /directory.php?category=$1&subcat=$2 [L,QSA]

Answer : Please check my mod_rewrite

Allow directory links to work with the trailing slash and without:

#no trailing slash
RewriteCond %{REQUEST_URI} !/$
#and it's not path to valid file(so either dir or nonexistent), checking for dot only is not the best option here
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* %{REQUEST_URI}/ [R=301,L]

pretty normal rewrites look fine, hence You may want to add the [QSA] option - You already know what it means.


Cut down the huge url of the directory:
Oh, i know the code ;) So I guess I have to say it's OK. One little note.
It allows the ending slash to be missing "^([^/]+)/([^/]+)/?$" - the question mark says, the slash is optional - but it's OK i guess.
Random Solutions  
 
programming4us programming4us