fmmarzoa Posted October 27, 2007 Share Posted October 27, 2007 Hi there, I've an apache 2.0 server which uses mod_rewrite within a linux box. Every request that's not a file, directory or symlink should be handled by a PHP script called 'browser.php'. So, I've added an unique rule to mod_rewrite on my .htaccess: <IfModule mod_rewrite.c> RewriteEngine On ## Everything is handled now by browser.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ browser.php [QSA,L] </IfModule> For simplifing, let's say that I've this structure under my virtual host public root directory: /browser.php /flights.xml Now, if I try to open the following URL: http://mydomain/flights/ For some unknown reason, Apache tries to open http://mydomain/flights.xml/ instead and it gives a 404 error :-? But if I remove the file flights.xml, then it calls browser.php as expected and everything works fine. ??? So, anyone knows why Apache is trying to open /flights.xml/ when I request /flights/ just because the first exists instead of calling my browser.php as mod_rewrite rules? Thanks a million in advance, (and excuse my english, BTW). Quote Link to comment https://forums.phpfreaks.com/topic/74988-solved-apache-tries-to-open-wrong-files-adding-extension-automatically-and-wrongly/ Share on other sites More sharing options...
fmmarzoa Posted October 29, 2007 Author Share Posted October 29, 2007 I found the solution in other forum: http://www.webmasterworld.com/apache/3161107.htm Sounds like you may have MultiViews/content-negotiation enabled, which will grab the URL and try to find a "best match" to the requested URL. In the absense of a better, closer match, it will choose "index.inc" as a match for "index". This of course interferes with your file-exists test and rule. Try preceding your code with Options -MultiViews to disable it and see if that helps. If you already have an Options statement like "Options +FollowSymLinks -Indexes" in your code, you can add "-MultiViews" to the end of that line, so you get something like Options +FollowSymLinks -Indexes -MultiViews Thanks anyway. Quote Link to comment https://forums.phpfreaks.com/topic/74988-solved-apache-tries-to-open-wrong-files-adding-extension-automatically-and-wrongly/#findComment-380214 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.