views:

55

answers:

1

My current solution is to put everything in the site root although it gives the desired result it has crowded my root folder (more than 200 cities). I would like to put all the cities in /root/cities/ folder and rewrite so that it looks like they are in the root folder.

www.foo.com/cities/citypage(.html) to www.foo.com/citypage(.html)

A: 

You could use a rule that checks whether there is such a file in the cities folder:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}cities%{REQUEST_URI} -f
RewriteRule !^cities/ cities%{REQUEST_URI} [L]

RewriteCond %{THE_REQUEST} ^GET\ /cities/([^\s?]*)
RewriteRule ^cities/ /%1 [L,R=301]
Gumbo