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.

I'm trying to get the directories in my /var/www/html/ directory to not show the "index of..." and all files residing in it. Do I need to edit httpd.conf and put .htaccess files in each directory to ensure the contents are hidden? I have Apache version 2.2.3 on CentOS 5.

Is this the part of httpd.conf I need to edit?

<Directory "/var/www/error">
    AllowOverride None
    Options IncludesNoExec
    AddOutputFilter Includes html
    AddHandler type-map var
    Order allow,deny
    Allow from all
    LanguagePriority en es de fr
    ForceLanguagePriority Prefer Fallback
</Directory>

Do I put a .htaccess file with this in each directory?

Options -Indexes 
share|improve this question

3 Answers 3

up vote 5 down vote accepted

If you can edit the main config file then add -Indexes to your Options line

Options IncludesNoExec -Indexes

and restart your apache service.

It's doing this because there is no DirectoryIndex file. You could just put a blank index.html file in your directory. You could add the -Indexes to a .htaccess too.

share|improve this answer
    
Thanks for the response I changed the Options in <Directory "/var/www/error"> only. I restarted httpd and it didn't work. Is there another part of the conf file I need to change? –  user1062058 Dec 21 '11 at 19:02
    
I also made an .htaccess file in a directory with Options IncludesNoExec -Indexes and restart apache. No luck there either. –  user1062058 Dec 21 '11 at 19:07
    
Yes, you need to find the <Directory /var/www/html> configuration block. –  Iain Dec 21 '11 at 19:08
    
<Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> Should I make "Options Indexes FollowSymLinks" "Options Indexes FollowSymLinks -Indexes" or "Options IncludesNoExec -Indexes" –  user1062058 Dec 21 '11 at 19:15
    
The latter should do it. –  Iain Dec 21 '11 at 19:16

in your http.conf just add the -Indexes to your options.

IE

<Directory "/var/www/error">
    AllowOverride None
    Options IncludesNoExec -Indexes
    AddOutputFilter Includes html
    AddHandler type-map var
    Order allow,deny
    Allow from all
    LanguagePriority en es de fr
    ForceLanguagePriority Prefer Fallback
</Directory>
share|improve this answer

I know I'm late, but it makes sense to just disable the corresponding module:

# a2dismod autoindex
share|improve this answer

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.