5

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.

2 Answers 2

18

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.

1
  • Thanks that was it! Didn't upvote just cause I can't :) Dec 18, 2009 at 20:08
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .