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 
link|improve this question

feedback

3 Answers

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.

link|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
show 2 more comments
feedback

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>
link|improve this answer
feedback

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

# a2dismod autoindex
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.