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.

When I ask the server for an URL which has no extension, but is not a directory, apache automatically adds a .php extension to it. Where is this behavior configured?

EDIT: I'm sorry, my question wasn't clear: I'm not asking how to do this, I just found out that my local server (Apache/2.2.11 on Debian) does it by itself (i.e. I have no rewrite rules) and I wanted to know where this can be configured.

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

Debian (speaking current versions as you mention Apache 2.2.11 which falls somewhere between Lenny and Sid) has the MultiViews option enabled for /var/www and /usr/share/doc directories by default in /etc/apache2/sites-enabled/000-default. With this option enabled Apache will attempt to match a URI request to any file with an extension it knows about. That said if the URI is requesting /test it will attempt things like test.php, test.html, test.txt, etc until it finds a match.

share|improve this answer
    
Thanks that was it! Didn't upvote just cause I can't :) –  Matteo Riva Dec 18 '09 at 20:08
add comment

There's a few ways to do this. I'd use a mod_rewrite approach:

  • let any url ending in .php (.jpg, etc) pass through, last rule if match
  • rewrite the URL to end in .php, last rule if match
share|improve this answer
add comment

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.