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

I noticed apache2 will load a page, let's say info.php, even if the url is specified without a file extension like

I thought you would need to do a mod_rewrite of some form to get that functionality but apparently it's the default functionality in my system.

Is there any way to prevent this default behavior so only pages with file extensions can be specified?

I have rewrite disabled fyi.

share|improve this question
up vote 3 down vote accepted

What you are running into is a piece of one of the core modules of apache: mod_dir.

The directive you want to look for is DirectoryIndex this tells apache to look for certain file names when there is no absolute filename specified. The default is generally a line that looks like:

DirectoryIndex index.html index.php default.html default.php

If you don't want to have it search for these files, and display them by default you need to find the DirectoryIndex line in you apache config file and either comment it out or get rid of everything after the DirectoryIndex statement.

share|improve this answer
Thanks, you're handle reminds me of zephyr song lol – user784637 Mar 5 '12 at 23:01
I'm pretty sure this is wrong. mod_dir only handles the typical files, like index.* and default.*. Note that he described "info.*" which would be really bizarre to find as a value for DirectoryIndex. – Insyte Mar 6 '12 at 8:54

The magic you're seeing is performed by the MultiViews option of mod_negotiation.

From the Apache docs:

If the server receives a request for /some/dir/foo and /some/dir/foo does not exist, then the server reads the directory looking for all files named foo.*, and effectively fakes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client's requirements, and returns that document.

Disable this magic by turning off MultiViews either in the apache config or in a .htaccess file:

Options -MultiViews
share|improve this answer
+1; MultiViews seems more likely than DirectoryIndex in this case. – nickgrim Mar 6 '12 at 9:39

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.