Search at Knowledgebase
How to disable Directory Browsing on Apache

Objective

Enables default indexing on the Apache webserver using the Options + Indexes or Options indexes directory. This usually happens when the index (default) file is not available in the directory. Apache does not understand which file should be displayed on the page and which should list all the files on the page. See the below screenshot as there is no index file available.
See the instructions for disabling Directory Browsing on Apache.

1. First you need to activate the .htaccess file for your website in the master apache configuration file. Run the below command to edit the configuration file and then look for the section that is shown in the below image, change the value of the AllowOverride None directive to AllowOverride All, then save and exit.

# vi /etc/httpd/conf/httpd.conf

2. To disable directory listing for a specific directory, create a .htaccess file in that directory with the content below.

Options -Indexes

3. Restart the Apache server with the below commands.
On SystemD based systems

# systemctl restart apache2
# systemctl restart httpd

On SysVInit based systems

# /etc/init.d/apache2 restart
# /etc/init.d/httpd restart

4. Now reload the website and the page will show “You don’t have permission to access / on this server”

Your FREE Trial Starts Here!
Contact our team for application of dedicated server service!
Register as a member to enjoy exclusive benefits now!
Your FREE Trial Starts here!
Contact our team for application of dedicated server service!
Register as a member to enjoy exclusive benefits now!
Telegram Skype