Jump to content

[SOLVED] Apache tries to open wrong files adding extension automatically and wrongly


fmmarzoa

Recommended Posts

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  :o 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).

 

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.