DirectoryIndex (normally configured as
welcome.html) present in a directory, and if
mod_autoindex is enabled (which by default is normally enabled),
Apache would list the directory contents, as the following;
While useful for some cases, you would want to disable this feature (perhaps for security reason). There are few ways to do this.
The easiest way is probably to disable the autoindex module entirely. This would affect all the sites hosted on the server, which could be both good and bad.
The module is called
autoindex, and can be disabled by the
a2dismod command, as in the following example.
sudo a2dismod autoindex
Directory’s Options directive
The option could be applied per-directory, via the
Option directive as the following.
<Directory /var/www/mysite> Options -Indexes </Directory>
This could be set in your
Apache‘s configuration file.
The above method would also work by adding a
.htaccess file with the following content that you want directory listing to be disabled.
– See more at: https://docs.oseems.com/general/application/apache/disable-directory-listing#sthash.LwlHWb8u.dpuf