How To Disable Directory Browsing in WordPress


Directory browsing is enabled by default in most web hosts. This is very insecure as anyone can browse through your web directories and gather the information regarding the plugins and themes you are using.

This information, in turn, is used to attack your site using the vulnerabilities found in your plugins, themes, and other files.

So, let me show you how to disable directory browsing in WordPress to protect your WordPress site and keep sneaky eyes off your server directories.

In this article, I’m going to show the process in two different methods, i.e. using a .htaccess rule and from the cPanel options. Follow the procedure that you are most comfortable with.

Disable Directory Browsing from cPanel

The first method to disable directory browsing in WordPress is to use the built-in options in the cPanel. If you don’t have access to the cPanel then follow the .htaccess method show below.

1. To disable directory browsing in the cPanel, login to your cPanel and click on the link “Index Manager” appearing in the “Advanced” section.


2. The above action will open the directory selection window. Select the “Web Root” option and click on the “Go” button.


3. This will take you to the index manager, here select the folder you want to disable directory listing. Generally, you have to select “public_html” or “www” directory.


4. Here in this window, select the radio button “No Indexing” and click on the button “Save” to save changes.


5. That’s it. You have disabled directory browsing in WordPress.

Disable Directory Browsing Using .htaccess Rule

Disabling directory browsing using .htaccess rule is really simple. All you have to do is to edit the file to add a rule. Do backup the file before editing it.

1. To start off, log into your FTP account. You can use any of the free FTP clients like CyberDuck or FileZilla.

2. Once logged in, navigate the root directory, find and open the “.htaccess” file. Since the .htaccess is a hidden file, make sure that you have enabled your FTP client to show hidden files.

3. After opening the file, add the below rule on top of the .htaccess file.

# Disable Directory Browsing
Options -Indexes

Once you have added, just save and re-upload the file. That’s all there is to do. You have successfully disabled the directory browsing in your WordPress site.

That’s all there is to do. it is that simple to disable directory browsing in WordPress using the cPanel and a simple .htaccess rule.

Hopefully that helps and do comment below of you face any problems while disabling directory browsing in WordPress.

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.