How to Disable Directory Listing on Your Web Server

Disabling directory listing is one of the security best practices that helps to protect your site effectively. That means users are not be able browse and view your WordPress folders and sub-directories.

In this article, we will show you how to disable directory listing on some popular web servers such as Apache, NGINX and Microsoft Internet Information Services (IIS).

Apache server

If you’re using Apache, simply enable Disable Directory Listing option available in both PDA Lite and Gold plugins.

Once the option is enabled, our plugins will add the following code line to your .htaccess file automatically.

Options -Indexes

NGINX server

Step 1: Find and open your website’s Nginx config file which is normally located at /etc/nginx/site-available (or /etc/nginx/conf/site-available if you’re using Arch Linux).

Step 2: Add autoindex on inside the server block as below.

server {

    location / {
		autoindex on;

Step 3: Restart your Nginx server.

IIS server

Add the following codes in your web.config file located at your WordPress website’s root folder.

If the web.config file does not exist, simply create a new one.

  <directoryBrowse enabled="false" /> <!--this line will disable directory browsing-->     
Lasted updated on April 13, 2021