Ashish Singh

Web Hacking. Typify.

When Options -Indexes in .htaccess Doesn't Work

| Comments

We’ve our sandbox server running on Amazon EC2. There are a lot of projects hosted there with each project’s .htaccess taking care of it. Apart from the various tasks that the .htaccess does, it restricts directory browsing using simple directive

1
2
3
<IfModule mod_autoindex.c>
  Options -Indexes
</IfModule>

But somehow on the root folder of the sandbox, this directive didn’t work. This implies, a directory specific directive was somewhere being issues. These are a few places to look for

1
2
3
/etc/apache2/httpd.conf
/etc/apache2/apache.conf
/etc/apache2/sites-enabled/000-default

In our case, the below directives were present in the /etc/apache2/sites-enabled/000-default file.

1
2
3
4
5
6
7
8
9
10
11
DocumentRoot /var/www
<Directory />
        Options FollowSymLinks
        AllowOverride None
</Directory>
<Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews Includes
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>

This was changed to

1
2
3
4
5
6
7
8
9
10
11
12
13
DocumentRoot /var/www
<Directory />
        #Options FollowSymLinks
        Options -Indexes
        #AllowOverride None
</Directory>
<Directory /var/www/>
        #Options Indexes FollowSymLinks MultiViews Includes
        #AllowOverride None
        #Order allow,deny
        #allow from all
        Options -Indexes
</Directory>

and it worked!

Comments