Disable directory listing in Apache

Browse to the Apache configuration folder on disk. On Ubuntu this is for example /etc/apache2/sites-available. Edit the file default.

Look for the section that looks similar to:

<Directory /[some directory name]>

and you should see something like the following in the next line:

Options Indexes FollowSymLinks

To disable directory listing, just remove Indexes from this line or change Indexes to -Indexes to disable it.

Make sure to restart your Apache server after making the change to make it effective. That’s it! Directory listing should be disabled now by default!

If you want to enable directory listing for a specific directory added Index to the configuration for that directory.