I’m trying to get http://www.example.com and http://www.example.com/index.html to go to index.html, but I want all other urls e.g. http://www.example.com/this/is/another/link to still show http://www.example.com/this/is/another/link but be processed by a generic script. I’ve tried
RewriteEngine on
RewriteCond %{REQUEST_URI} !^index\.html$
RewriteCond %{REQUEST_URI} !^$
RewriteRule ^(.*)$ mygenericscript.php [L]
but it wont work, can someone please help?
Instead of testing what
%{REQUEST_URI}is, you can instead just test if the resource exists:This prevents your static resources (images, stylesheets, etc.) from being redirected if they’re handled through the same directory your
.htaccessis in as well.What’s probably happening now is that you’re seeing an internal server error, caused by an infinite internal redirection loop when you try to access anything that isn’t
/or/index.html. This is because.*matches every request, and after you rewrite tomygenericscript.phpthe first time, the rule set is reprocessed (because of howmod_rewriteworks in the context that you’re using it in).