Best Practices

WordPress Directory Browsing: Why and How to Disable It

Learn why WordPress directory browsing is a security risk and how to disable it. Prevent attackers from exploring your file structure and finding vulnerabilities.

A
Amanda Foster
6 min read
1,082 views
Disabling WordPress directory browsing for security

Directory browsing allows anyone to view the contents of directories on your web server. While this might seem harmless, it's a significant security risk that exposes your WordPress structure to attackers.

What is Directory Browsing?

When directory browsing is enabled, visiting a URL like yoursite.com/wp-content/uploads/2024/ displays a list of all files in that directory. Instead of a webpage, visitors see:

  • File names
  • File sizes
  • Modification dates
  • Subdirectories

Testing Your Site

Try accessing these URLs on your site:

  • yoursite.com/wp-content/
  • yoursite.com/wp-content/uploads/
  • yoursite.com/wp-content/plugins/
  • yoursite.com/wp-includes/

If you see a file listing instead of a 403 error, directory browsing is enabled.

Security Risks of Directory Browsing

1. Information Disclosure

Attackers can discover:

  • Which plugins and themes you're using
  • Plugin versions (from readme.txt files)
  • Backup files that shouldn't be accessible
  • Configuration files with sensitive data
  • Development files (.git, .env)

2. Vulnerability Targeting

Knowing your exact plugins and versions, attackers can:

  • Search for known vulnerabilities
  • Target version-specific exploits
  • Plan attacks more efficiently

3. Sensitive File Discovery

Directory browsing might expose:

  • Backup archives (.zip, .tar.gz)
  • Database dumps (.sql)
  • Log files with error details
  • Configuration files
  • Temporary files

4. Attack Surface Mapping

Complete file listings help attackers:

  • Understand your site structure
  • Find hidden directories
  • Identify custom code locations
  • Plan targeted attacks

How to Disable Directory Browsing

Method 1: .htaccess (Apache/LiteSpeed)

Add this line to your root .htaccess file:

Options -Indexes

Or more comprehensively:

Options All -Indexes

Method 2: nginx Configuration

Add to your server block:

autoindex off;

Method 3: Apache Main Config

In httpd.conf or apache2.conf:

<Directory /var/www/html>
    Options -Indexes
</Directory>

Method 4: WP Folder Shield

WP Folder Shield disables directory browsing automatically with one click:

  1. Navigate to WP Folder Shield > Settings
  2. Enable "Disable Directory Browsing"
  3. Save changes

Verifying Protection

After disabling, test by visiting:

  • yoursite.com/wp-content/uploads/

You should see a 403 Forbidden error, not a file listing.

Additional Directory Security Measures

Add Index Files

Create empty index.php or index.html files in directories to prevent listings even if Options -Indexes fails:

<?php // Silence is golden

WordPress already includes these in most directories.

Protect Specific Directories

Add extra protection to sensitive directories:

<Directory "/var/www/html/wp-content/debug">
    Order deny,allow
    Deny from all
</Directory>

Block Specific File Types

Prevent listing and downloading of sensitive files:

<FilesMatch ".(log|bak|sql|gz|zip)$">
    Order allow,deny
    Deny from all
</FilesMatch>

Common Issues

Caching Issues

If changes don't take effect, clear your browser cache and any server-side caching.

Hosting Restrictions

Some hosts override .htaccess settings. Contact support if rules don't work.

CDN Configuration

If using a CDN, ensure directory browsing is also disabled at CDN level.

Complete Directory Security with WP Folder Shield

WP Folder Shield provides comprehensive directory protection:

  • Disable directory browsing: One-click activation
  • Block PHP in uploads: Prevent webshell execution
  • Protect wp-includes: Block direct access
  • Hide sensitive files: Block .htaccess, wp-config access
  • File listing prevention: Return 403 for directory URLs

Get WP Folder Shield and secure your WordPress directories with one click.

Share:
A
Written by Amanda Foster

WP Folder Shield Team

Related Articles

Automated vs Manual WordPress Malware Scanning: Which is Better?
Automated vs Manual WordPress Malware Scanning: Which is Better?

Compare automated and manual WordPress malware scanning approaches. Learn when to use each method...

January 17, 2026
Preventing WordPress Malware: 10 Essential Security Practices
Preventing WordPress Malware: 10 Essential Security Practices

Learn 10 essential security practices to prevent WordPress malware infections. Protect your site...

January 13, 2026
Protecting Your WordPress Site from SEO Spam Injections - Complete Guide
Protecting Your WordPress Site from SEO Spam Injections - Complete Guide

Comprehensive guide to protecting your WordPress website from SEO spam injections, including...

January 12, 2026

Ready to Secure Your WordPress Site?

Get complete protection with WP Folder Shield.

Get Started