voodoo107 Posted August 6, 2008 Share Posted August 6, 2008 Hi everyone, I have noticed that all our company's (Debian) webservers with a recent version of Apache automatically map http://domainname.com/index to a matching entry in the DirectoryIndex directive (index.html, index.php, etc.). So, if there's an index.php present, Apache directs http://domainname.com/index to the index.php file. I don't (knowingly) have a mod_rewrite rule active doing this, it seems to be happening "by itself". I want to stop this behaviour as it's messing up a mod_rewrite rule I'm making because /index gets evaluated as being a file! Does anybody know where the configuration of this behaviour is? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/118428-urlindex-automatically-becomes-urlindexphp/ Share on other sites More sharing options...
texerasmo Posted August 7, 2008 Share Posted August 7, 2008 You might be more accurate? Quote Link to comment https://forums.phpfreaks.com/topic/118428-urlindex-automatically-becomes-urlindexphp/#findComment-610659 Share on other sites More sharing options...
voodoo107 Posted August 7, 2008 Author Share Posted August 7, 2008 You might be more accurate? Accurate? Do you mean specific? ??? The problem is quite simple. "http://www.mydomain.com/index" should normally (without a mod-rewrite rule active) lead to a 404 error, because "index" is not a valid file or folder in my webroot. Instead, Apache routes the "http://www.mydomain.com/index" request to whatever file is available from the DirectoryIndex directive (for example, index.php or index.html), effectively making it a direct call to for example "http://www.mydomain.com/index.html" internally (this doesn't show in the address bar of course). In my mod_rewrite rules I have set in the conditions to not rewrite files and folders with: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?route=$1 [L,QSA] What happens now is that in my MVC application http://www.mydomain.com/index/login does not get directed to the login action in my index controller file, but because /index gets evaluated as a file it doesn't fill the route $_GET variable through the rewrite action above. This is not a mod_rewrite issue I think (otherwise I'd have posted it in the correct sub-forum), my rewrite rules work fine (at least on my developent XAMPP installation). When I comment out the first rewrite condition (so files will get rewritten), my $_GET looks like "index.php/login" instead of "index/login" which it should be. I hope it's more clear now... Quote Link to comment https://forums.phpfreaks.com/topic/118428-urlindex-automatically-becomes-urlindexphp/#findComment-610702 Share on other sites More sharing options...
voodoo107 Posted August 11, 2008 Author Share Posted August 11, 2008 I have found the answer through another forum. I feel pretty stupid as it's actually quite simple. The server has Options MultiViews enabled by default which causes this behaviour. Adding Options -MultiViews to my .htacces solved everything. http://httpd.apache.org/docs/2.2/content-negotiation.html#multiviews Options -MultiViews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?route=$1 [L,QSA] Quote Link to comment https://forums.phpfreaks.com/topic/118428-urlindex-automatically-becomes-urlindexphp/#findComment-613302 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.