How to disable directory browsing on Apache


If it is not in a directory on the server found the default file (for example. index.html) may occur according to the server settings different situations. The default and potentially dangerous can display the contents of a directory, which displays links to file inside the directory.

Directory Internet Browsing

Deactivation for the entire server make by removing the options Options Indexes in the configuration file /etc/apache2/apache2.conf

<Directory /var/www/>

Options Indexes FollowSymLinks

</Directory>

If you would like opt in only some of directory. Create a new configuration file block that links to the directory (Docs)

<Directory /var/www/adresar/Docs>

Options Indexes FollowSymLinks

</Directory>

Or

In the desired directory (/var/www/adresar/Docs) edit the contents of a file .htaccess and add the following code:

Options Indexes

Links : Apache Module mod_autoindex, Option Directive.