Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using the php library tonic for web services. My resource is as example at

base-uri/myResource

Now if a file myResource.php exists in that directory, the url mod_rewrite gets to see is

base-uri/myResource.php

which then fails the rewrite conditions and my application breaks (app works on apache on windows)

If I rename myResource.php to my myResourceClass.php (or anything else), it works.

So it seem that apache or one if its modules assumes that with base-uri/myResource I want to call base-uri/myResource.php but only if myResource.php exists.

Is this a general issue or can I somewhere configure this to not happen?

thanks!

EDIT:

see

How to set up a basic mod_rewrite?

The answer contains the same observation!

ANSWER:

The issue is the default Apache configuration on Ubuntu:

Options Indexes FollowSymLinks MultiViews

MultiViews is changing request_uri from myResource to myResource.php.

Solutions:

  • disable MultiViews in .htaccess: Options -MultiViews
  • remove MultiViews from default config
  • rename the file as example to myResourceClass

I chose last option because that should work regardless of configuration and I only have 3 such files so the change took about 30 secs...

share|improve this question

2 Answers 2

up vote 1 down vote accepted

The issue is the default Apache configuration on Ubuntu:

Options Indexes FollowSymLinks MultiViews

MultiViews is changing request_uri from myResource to myResource.php.

Solutions:

  • disable MultiViews in .htaccess: Options -MultiViews
  • remove MultiViews from default config
  • rename the file as example to myResourceClass

I chose last option because that should work regardless of configuration and I only have 3 such files so the change took about 30 secs...

share|improve this answer

There's a very high chance that there's a .htaccess file in the folder that checks if something with .php exists as a file, and if so, add the .php extention.

My advice: check for a .htaccess file in the folder. If there's one, and my advice was not enough, then please add to your question so we can go further.

share|improve this answer
    
Yes. Just edited my question at the same time you responded. The issue is Apache Option "MultiViews". –  beginner_ Mar 23 '12 at 8:26
    
So don't put your answer in the question :) Just answer yourself and check it as valid in 24 hours =) –  Olivier Pons Mar 23 '12 at 8:27
    
With my reputation you have to wait 8 h before you can even add an answer and then wait another 24 h to accept it. Thats why i did it this way... –  beginner_ Mar 23 '12 at 15:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.