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

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.