Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Is it possible to turn apache's DirectoryIndex off for specific directory using .htaccess file? I've tried DirectoryIndex Off but if file Off exists it uses it as index file. I want to make sure that the directory will be listed no matter what files are inside.

share|improve this question
up vote 4 down vote accepted

You have a couple of options:

  1. Set DirectoryIndex to a filename that will never possibly exist.

    DirectoryIndex lni345hoqvgheruhgreoiuhgeroi30948yt0348
  2. Don't load the mod_dir module. This, however, will disable the index.html style functionality for the entire server, and is probably not what you want.

Beginning with Apache 2.4 you can set DirectoryIndex disabled to disable its functionality.

share|improve this answer

According to the documentation here, you can use:

DirectoryIndex disabled

to do this, either in your Apache config file, or in .htaccess.

share|improve this answer
Not available in 2.2, you seem to need 2.4 for that. – ptman Feb 21 '14 at 7:30

Correct syntax would be to disable indexes via options

Options -Indexes

Of course for this to work you need to have at least AllowOverride Indexes or AllowOverride all for this directory in order to have power to change this option via .htaccess in given directory.

share|improve this answer
I don't think you read his question correctly. He wants Indexes to always be displayed, even if the directory contains an index.html or similar file. – Michael Hampton Oct 2 '12 at 15:02
question is vague, I explained how directory indexes are disabled. – Hrvoje Špoljar Oct 2 '12 at 15:05
Vague? The question was perfectly clear. – Michael Hampton Oct 2 '12 at 15:12
He want's directory indexes off, but he wants them displayed... displayed from where? display what? indexes, random document if no files? – Hrvoje Špoljar Oct 2 '12 at 15:18

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.