Disable Directory Browsing in WordPress using .htaccess
Disable Directory Browsing in WordPress using .htaccess

By Default when the server can’t find the index file for example index.php or index.html it automatically shows us the directory files where we have uploaded the website content. This makes our website very easy to hack. If you haven’t disable directory browsing, anyone can browse your web directory. The directory reveals every information from theme files to WordPress plugin or images and all the information of your website. That’s why I highly recommend to disable directory listings. There are many plugins in the market which give you a chance to accomplish it with the assistance of plugins. One of the most used plugin is Disable directory listings.


It’s a smart thought to accomplish more work without utilizing plugin. In this article I will be sharing how you can stop directory browsing in WordPress using .htaccess technique.

If you are using plugins like WordPress SEO by yoast plugin or Robots meta plugin, you can easily alter your .htaccess file from your WordPress Dashboard. Else you have to use FTP client like FileZilla or Cuteftp to access your server files and then can change the .htaccess file. If you are using Mac OS then you can use Cyber duck. As we are discussing about the .htaccess method but I will explain how you can alter the .htaccess file in the bottom of this article. Now Let’s Just come back the track.

Once you are logged in to your website using FTP client, on the root directory you will see .htaccess file. If you are unable to locate the file then please ensure that you have enabled “show hidden files” option in the your FTP client because the .htaccess file is the hidden one. Now you will see the .htaccess file.

Note : Please save a copy of the file as a backup file.

You only need to add a single line at the bottom. Which is

Options -Indexes

Now Just save the file. That’s It. Your directory browsing is now disabled. If someone try to browse your WordPress directory he will automatically redirects to error 404 page of your WordPress website.

The Final Output of your .htaccess file will be :



If you want to update the file from SEO by yoast plugin just go to SEO > Edit Files and add the code then save the file.
If using Robots meta plugin Just reach settings > Meta robots and change the .htaccess file.

I really hope this article helps you a lot to disable directory browsing of your WordPress website and your blog is more secure. Keep Sharing the post.


Please enter your comment!
Please enter your name here