Apache
Enhance Security: Disable Directory Browsing on Apache Linux Remote Server/VPS
1 min read
#ApacheHow to Disable Directory Browsing on Apache
What is Directory Browsing?
Directory browsing allows anyone to view all the files and directories within a folder on your web server. This can pose a security risk as it may expose sensitive information.
Why Should We Disable Directory Browsing?
Disabling directory browsing is crucial for security. It prevents unauthorized users from accessing and potentially exploiting sensitive information on your server.
Method 1: Disable in Apache Configuration
-
Open Apache Configuration File
sudo nano /etc/apache2/apache2.conf
-
Locate the Directory Block
Find the following content:
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
-
Modify the Directory Block
Change the
Options
line to:<Directory /var/www/> Options FollowSymLinks AllowOverride None Require all granted </Directory>
-
Restart Apache
sudo service apache2 restart
Method 2: Disable in Virtual Hosts File
-
Navigate to Sites-Available Directory
cd /etc/apache2/sites-available
-
Open the Virtual Host File
sudo nano 000-default.conf
-
Add Directory Configuration
Add the following content:
<Directory /var/www/html/> Options FollowSymLinks AllowOverride None Require all granted </Directory>
-
Restart Apache
sudo service apache2 restart