Change the site configuration file to block listing out files in the directory - apache2 + Ubuntu
When I access a directory hosted by Apache that does not have a index.php
file or similar, Apache lists the content of the directory for me. How can I block this? I'm using Apache2 on Ubuntu.
In the appropriate <Directory>
stanza. For instance it may look like this:
<Directory /www/somefolder>
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
Change this into
<Directory /www/somefolder>
Options -Indexes FollowSymLinks
AllowOverride None
</Directory>
If there is no Options...
line, you can add one with the content Options -Indexes
for any <Directory...>
stanza. The options are separated by a space ().
Note the - in front of Indexes. This is also covered briefly in the Apache documentation.
The index are generated by mod_autoindex.