.htaccess pt2

Jul 25, 2007 16:55

Well, last I checked, no one had responded to my .htaccess questions. Which is fine now, as I've figured out the problem. I reordered and added some conditions, and just like that, everything I needed to do was solved. A reminder, here was the problem:

with respect to the XXXXX at the end of www.mytopsecretdomain.com/XXXXX
* allow any XXXXX to be a valid rails controller
* allow XXXXX to be a valid directory
* allow XXXXX to be a valid filename
* allow an empty XXXXX to easily be rerouted between a default .html file and a default rails controller

end result:

RewriteBase /

# rewrite empty string to index.html
RewriteRule ^$ index.html [QSA]

# as long as it's not a directory,
# rewrite /xxx and /xxx/ to /xxx.html .... i'm actually not so sure why this is useful, but it was a preexisting rule... sooo..
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.html [QSA]

# if it's not a filename and it's not a directory
# route that text as a command to rails
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
Previous post Next post
Up