How to disable directory indexing from apache2 when going to the server's root?

Edit your apache2 configuration file which normally is on the dir: "/etc/apache2/httpd.conf".

Add the following or edit if your already have some configurations for the default web server dir (/var/www):

 <Directory /var/www>
   Options -Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
 </Directory>

This will disable the indexing to all the public directories.


Usually done like this:

Options -Indexes

The minus means "no"...


If it's only one directory that you want to protect from viewing contents, you can also just add an index.html or index.php that will show whenever someone browses to that directory.