apache2

How To Disable Directory Listing in Apache

Disable directory listing on Apache; but access to individual files should be allowed.

If you are using Debian/Ubuntu, just go to terminal and type

sudo a2dismod autoindex
sudo service apache2 restart

If you are using Centos/Fedora, just do:

mv /etc/httpd/conf.d/autoindex.conf /etc/httpd/conf.d/autoindex.bkp
/etc/init.d/httpd restart

# sudo a2dismod autoindex
WARNING: The following essential module will be disabled.
This might result in unexpected behavior and should NOT be done
unless you know exactly what you are doing!
autoindex

To continue type in the phrase ‘Yes, do as I say!’ or retry by passing ‘-f’:Yes, do as I say!
Module autoindex disabled.
To activate the new configuration, you need to run:
systemctl restart apache2

# systemctl restart apache2