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.

How can I configure Apache to list files in a directory even if an index file is present?

For example, if I have a directory /var/foo that contains a number of files, and one of those is a directory index (index.html, index.php, etc.), how can I make Apache show the directory listing instead of displaying the contents of index.html, when a user browses to http://example.com/foo/?

# Directory listing for /var/foo/, mapped to http://example.com/foo/
..
.
code.c
readme.pdf
index.html

I have used the following but I would imagine there's a better way:

Options +Indexes +MultiViews
DirectoryIndex will-never-exist.xyz
share|improve this question
    
nice question for an starter –  Mughil Dec 31 '11 at 18:39
    
I'm a frequent Stack Overflow user so I know my way around the network. ;) –  Jake Petroules Jan 1 '12 at 4:41

2 Answers 2

up vote 5 down vote accepted

You may leave DirectoryIndex option empty or just turn off dir_module module.

share|improve this answer
    
Leaving the option empty doesn't work for me with apache-2.2.14, index.html still gets used. –  David Grellscheid May 23 '12 at 10:53
    
Check your config, it's assigned somewhere. Try to disable module –  Selivanov Pavel May 23 '12 at 13:44
    
@Selivanov: got the same problem (tried both empty DirectoryIndex and quoted empty string DirectoryIndex "", defined at the root of my VHost). But when I specify a non-existent file (or disable the module), it works so it's not overriden somewhere else (AFAICT). –  Tibo Feb 6 '13 at 10:13

The DirectoryIndex directive can be limited in scope with a Directory block

<Directory /path/to/directory/to/list>
    Options +Indexes +MultiViews
    DirectoryIndex will-never-exist.xyz
</Directory>

This limits the scope to the particular directory rather than your vhost or server etc.

share|improve this answer
1  
My question was how to disable a DirectoryIndex already in effect, not how to limit scope to a directory... –  Jake Petroules Dec 31 '11 at 11:12
    
You should rewrite your question to be clearer about your goal then. –  Iain Dec 31 '11 at 11:14
1  
I think it's worded fairly clear but I'll try to improve it. –  Jake Petroules Dec 31 '11 at 11:20

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.