Monday, August 22, 2016

How to prevent directory listing in Apache 2

If you are using Apache 2 as a web server on Linux, you might have seen that directory listing is enabled by default.

Directory listing allows anyone to view all the files and subfolders contained in a specific folder, by entering the URL on the browser. The image below is an example of the directory listing that you could see when you visit the fictitious URL

This might affect some privacy protection rules. In order to disable directory listing, you just need to type the following command from the terminal:

sudo a2dismod autoindex