2

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 
6

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.

| 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. – user9517 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. – user9517 Dec 21 '11 at 19:16
3

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>
| improve this answer | |
0

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

# a2dismod autoindex
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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