I have a site set up complete with an index, etc. I would like to redirect only traffic coming directly to www.example.com to www.example.com/foo.php. However, if a user tries to access www.example.com/index.php or any of the other existing pages directly, the request should return the appropriate page as normal. I can’t seem to wrap my head around these rewrite rules. How would I accomplish this with .htaccess?
I have a site set up complete with an index, etc. I would like
Share
You could likely get away with just changing the
DirectoryIndexto/foo.php:However, if you wanted to use
mod_rewriteto actually rewrite the URL, there are a few different ways to accomplish this, but the clearist is to just check if the requested resource is an empty string (the root was requested, and the input toRewriteRulein.htaccessfiles doesn’t contain a leading slash):Any request to the server that is not for
/will simply be ignored and routed by Apache as normal.