Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

3 Answers 3

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

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

According to the doc here, you can use

DirectoryIndex disabled

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

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

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.