Directory browsing allows anyone to see all the files in a folder and their contents.
Directory browsing can put your site at risk by showing important information to hackers which can be used to exploit vulnerabilities in website or hosting server.
- Open the /etc/apache2/apache2.conf file.
nano /etc/apache2/apache2.conf
- Find below content
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
- Change Above content to below Content
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
- Restart Apache
service apache2 restart
- Go to /etc/apache2/sites-available
cd /etc/apache2/sites-available
- Open the Required Virtual Host File
nano 000-default.conf
- Add below Content
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
- Restart Apache
service apache2 restart