1

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

2 Answers 2

1

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

0

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.

3
  • Yes. Just edited my question at the same time you responded. The issue is Apache Option "MultiViews". Commented Mar 23, 2012 at 8:26
  • So don't put your answer in the question :) Just answer yourself and check it as valid in 24 hours =) Commented Mar 23, 2012 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... Commented Mar 23, 2012 at 15:34

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.