Rob Bednark Rob Bednark - 3 months ago 18
Apache Configuration Question

.htaccess file not being read ("Options -Indexes" in .htaccess file not working)

I created an .htaccess file with only the following line:


Options -Indexes


However, the index is still shown for the directory.

I just installed Apache2 and am using all the defaults (I did not modify apache2.conf or httpd.conf).

OS:
Ubuntu 12.04 (Precise Pangolin)


Apache2 version:
Server version: Apache/2.2.22 (Ubuntu) Server built: Feb 13 2012 01:51:56



$ ls -l .htaccess

-rwxr-xr-x .htaccess


EDIT:

I took lanzz's advice and added gibberish to the
.htaccess
file, and discovered that the
.htaccess
file is not being read.

Answer

To get this working, I added the following to /etc/apache2/httpd.conf (which is a zero-length file by default when Apache is installed) and then restarted Apache. Now Options -Indexes in the .htaccess file works as desired. Here is the bare minimum required to get it to work:

/etc/apache2/httpd.conf :

<VirtualHost *:80>
        DocumentRoot /var/www
        <Directory / >
        </Directory>
</VirtualHost>

lanzz's suggestion to add a line of gibberish to the .htaccess file to see if it was being read was helpful in diagnosing the problem.

Note that AllowOveride defaults to All, per Evan Mulawski's comment, so it's not required in the minimal set of httpd.conf lines above.