low risk

How to Disable Directory Listing in WordPress

When directory listing is enabled, visiting a folder without an index file (like /wp-content/uploads/) shows every file inside. That hands attackers a map of your plugins, uploads, and backups.

  1. 1

    Disable it in .htaccess (Apache)

    Add this line to your site's root .htaccess file:

    Options -Indexes
  2. 2

    Disable it in Nginx

    Nginx doesn't list directories by default, but if autoindex was turned on, disable it:

    autoindex off;
  3. 3

    Add index files as a backup

    WordPress ships empty index.php files in its folders for this reason. Make sure they exist in custom upload directories too.

Is your site affected?

Run a free external scan — 36 checks, no login or plugin required.

Scan your site free

More fix guides