Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 13 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

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

Your Answer


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.