How to Turn Off Directory Indexing on WordPress
Add Options -Indexes above the WordPress block in .htaccess, or remove autoindex on in Nginx, then confirm uploads returns 403. Fixes for 500 errors too.

To turn off directory indexing on a WordPress site running Apache, add the line Options -Indexes to the .htaccess file in your site root, above the # BEGIN WordPress marker, then load /wp-content/uploads/ in a browser. A 403 Forbidden page means the listing is gone. On Nginx, directory listing is off unless someone wrote autoindex on; into the config, so the fix there is to find and remove that line.
That is the whole fix for most sites. The rest of this guide is for the cases where it does not work: the 500 error some hosts throw, Debian servers that ignore .htaccess completely, security plugins that write the line for you, and the “Index of” pages that are already sitting in Google. We tested every Apache behaviour below on Apache 2.4.67 with a WordPress 7.1.4 file layout on 18 November 2026, and checked the Nginx and OpenLiteSpeed details against their official documentation the same day.
What is directory indexing on WordPress?
Directory indexing is a web server feature, not a WordPress one. When someone requests a URL that ends in a folder, such as https://example.com/wp-content/uploads/2026/11/, the server looks for an index file in that folder. On a WordPress server that list is usually index.php and index.html. If neither file exists and indexing is allowed, the server builds a page on the fly that lists every file and subfolder, with sizes and dates. The page title starts with “Index of”.
On Apache the listing comes from mod_autoindex and is switched on by the Indexes value of the Options directive. On Nginx it comes from the autoindex module. OpenLiteSpeed has its own Auto Index setting.
WordPress itself never asks for a listing. It cannot switch one on or off either, which is why there is no setting for it in the dashboard.
Is directory browsing a security risk for a WordPress site?
It is an information leak, not a break-in. Nobody gets into your admin area because a folder is listable. What they get is a map. MITRE files this pattern as CWE-548, Exposure of Information Through Directory Listing, and the risk depends entirely on what sits in the folders.
On a typical WordPress site, the folders that matter are these:
/wp-content/uploads/and its year and month folders. WordPress core ships noindex.phphere. A listing shows every file ever uploaded, including images you deleted from posts but not from the Media Library, PDFs meant only for members, and files that form or LMS plugins drop into their own subfolders.- Plugin folders. Core places a “Silence is golden”
index.phpin/wp-content/plugins/, but most individual plugin folders have no index file. A listing there shows the plugin’s files and itsreadme.txt, which usually states the version. That tells an attacker which known vulnerability to try. - Backup, export and log folders. Backup plugins, import tools and some cache plugins write ZIP files, SQL dumps, CSV exports or logs under
wp-content. If one of those folders is listable, the file name is no longer a secret. /wp-includes/subfolders. These have no index files either. A listing here leaks little beyond your core version, but it still shows a scanner the server is loosely configured.
A listing does not make a private file public. If a file sits in a web-served folder, anyone with the URL can already download it. What the listing removes is the guessing. Upload folder paths follow the /YYYY/MM/ pattern, so a scraper that can list them can pull your whole archive in minutes.
So yes, turn it off. Just do not treat it as the fix for files that should never have been public. Those need to move out of the web root or behind a login. Our guide to hardening a site that accepts member uploads covers that part.
How do I check if directory listing is enabled on my site?
Request a folder that has no index file and look at what comes back. The fastest test is from a terminal. Replace the domain with yours.
# Checked on 18 November 2026. Expect 403 (or 404) for every line.
for path in wp-content/uploads/ wp-content/uploads/2026/ wp-includes/js/ wp-content/plugins/akismet/; do
printf '%s ' "$path"
curl -s -o /tmp/listing.html -w '%{http_code} ' "https://example.com/$path"
grep -o 'Index of[^<]*' /tmp/listing.html | head -1
echo
doneRead the result like this:
Response | What it means | Action |
|---|---|---|
200 plus “Index of” | Listing is on for that folder | Fix it with one of the methods below |
200 with a blank page | An | Fine for that folder only |
403 Forbidden | Listing is off, the folder exists | Nothing to do |
404 Not Found | The folder does not exist, or a plugin hides it | Pick a folder you know exists and test again |
500 Internal Server Error | An | See the 500 error section below |
Swap akismet for a plugin you actually run, and add any folder a plugin told you it creates, such as a backup or log folder. No terminal? Open the same URLs in a private browser window. You can also see what Google already holds with the search site:example.com intitle:"index of".
How do I turn off directory indexing with .htaccess?
Open the .htaccess file in your WordPress root, the same folder that holds wp-config.php, through your host’s file manager, SFTP or SSH. Download a copy first so you can put it back in seconds. Then add this block at the very top, above the WordPress section:
# Checked on 18 November 2026 (Apache 2.4.67)
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
# BEGIN WordPress
# ... leave the WordPress rules exactly as they are ...
# END WordPressSave, then run the check from the previous section. Every folder without an index file should now answer 403.
A few details matter here.
- Put it outside the markers. WordPress rewrites everything between
# BEGIN WordPressand# END WordPresswhenever permalinks are saved. The core function insert_with_markers() even writes a warning into that block: “Any changes to the directives between these markers will be overwritten.” Lines above or below the block are left alone. - The minus sign matters.
Options -Indexesremoves one option and keeps the rest, such asFollowSymLinks, which WordPress pretty permalinks need. WritingOptions NoneorOptions FollowSymLinksalso kills the listing, but it replaces every option for that folder tree, so it can switch off things your host turned on. - The rule covers subfolders. One line in the root
.htaccessapplies towp-content,uploadsand everything below them, unless a deeper.htaccessturnsIndexesback on. - The IfModule wrapper is optional. It only means the line is skipped if
mod_autoindexis not loaded, which is harmless because without that module there is no listing to switch off.
If you would rather leave the root file alone, the same block works in a .htaccess placed inside /wp-content/uploads/ only. That protects the folder that leaks the most and touches nothing else. For other rules worth adding to the same file, see our .htaccess optimization and security rules guide.
Why did adding Options -Indexes give me a 500 error?
Because the server does not allow Options lines in .htaccess files. Apache decides what each .htaccess may change through the AllowOverride directive in the main config. If AllowOverride does not include Options, Apache refuses the request and logs “Options not allowed here”. Your visitors see a 500 error on every page under that folder.
We reproduced each case on a test Apache server with listing switched on in the main config and a .htaccess in the uploads folder:
AllowOverride in the main config | .htaccess contains | Result for /wp-content/uploads/ |
|---|---|---|
| (no file) | 200, full “Index of” listing |
|
| 200, listing still shown. The file is never read |
|
| 500, error log says “Options not allowed here” |
|
| 403, listing off |
|
| 403, listing off |
|
| 200, “Index of” page still shown, just with no files listed |
That table explains most of the confusing reports. On a 500, delete the line to get the site back, then do one of two things. Ask your host to allow Options overrides, or ask them to switch indexing off for your account in the server config, which is the better fix anyway. Hosts that block the override often have listing off at server level already, so run the check first.
WP Rocket’s documentation describes the same error coming from its own cache folder, because the plugin writes Options -Indexes into wp-content/cache/wp-rocket/.htaccess to stop browsing there. If the 500 names a plugin’s folder rather than your root, that plugin wrote the line, and its support team or your host can tell you whether to remove it.
How do I disable directory browsing in the Apache config instead?
If you manage the server, fix it in the virtual host and skip .htaccess entirely. This matters more than it sounds, because Debian and Ubuntu ship a default apache2.conf with this block for /var/www/:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>That is listing on, with .htaccess files ignored. A WordPress site dropped into /var/www/html on a fresh Debian server lists its upload folders, and an Options -Indexes line in .htaccess changes nothing. (Pretty permalinks also fail on that default, which is usually the first hint.)
Upstream Apache is safer: since version 2.3.11 the default for Options is FollowSymlinks alone, per the Apache core docs. The listing only appears because a distribution or a host config added Indexes.
Edit the <Directory> block for your site, usually in /etc/apache2/sites-available/ on Debian and Ubuntu or /etc/httpd/conf.d/ on RHEL-family systems:
# Checked on 18 November 2026
<Directory /var/www/html>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>Then test the syntax before you reload, so a typo does not take the site down:
# Debian / Ubuntu
sudo apachectl configtest && sudo systemctl reload apache2
# RHEL, AlmaLinux, Rocky
sudo apachectl configtest && sudo systemctl reload httpdAllowOverride All in that block is there for WordPress permalinks, not for the listing. If you prefer to keep .htaccess off for speed, copy the WordPress rewrite rules into the virtual host instead. The WordPress Apache HTTPD page lists them.
How do I turn off directory listing on Nginx?
You probably do not need to. The autoindex directive defaults to off in the official Nginx documentation, so an Nginx site only lists folders when someone switched it on. Nginx also never reads .htaccess files, so adding Options -Indexes to one does nothing on a pure Nginx server.
If your check found a listing, search the config for the line that enables it:
# Checked on 18 November 2026
sudo grep -rn "autoindex" /etc/nginx/Change autoindex on; to autoindex off; or delete it, then test and reload:
sudo nginx -t && sudo systemctl reload nginxTwo setups catch people out. Control panels like Plesk put custom Nginx lines in an “Additional nginx directives” box rather than in /etc/nginx/, so check there too; a Plesk forum thread shows a listing that only appeared after autoindex on; was added through that box. And when Nginx sits in front of Apache as a proxy, Apache usually serves the folder request, so the Apache fix and the .htaccess line apply again.
What about LiteSpeed and OpenLiteSpeed?
They behave differently from each other, so check which one your host runs. The server header in curl -I https://example.com/ usually says.
- OpenLiteSpeed controls listings with an Auto Index setting at server, virtual host or context level in its WebAdmin console. The OpenLiteSpeed docs say “By default, Auto Index is disabled.” Its
.htaccesssupport centres on rewrite rules, so do not rely onOptions -Indexesthere. If a listing shows, set Auto Index to No in WebAdmin. - LiteSpeed Enterprise, common on shared hosting, reads Apache-style configuration and
.htaccessfiles. Add the.htaccessblock, then run the curl check to confirm it took effect on your host.
Either way, the curl check is the only proof that counts. A config line that looks right means nothing until the folder returns 403.
Can I use a blank index.php file instead?
Yes, and WordPress core does exactly that. The files wp-content/index.php, wp-content/plugins/index.php and wp-content/themes/index.php contain nothing but the comment // Silence is golden. Because an index file exists, the server runs it and returns an empty page instead of a listing.
<?php
// Silence is golden.The catch is coverage. The file only protects its own folder, not the folders below it. WordPress creates a new month folder in uploads every month and never adds an index file to it, and plugins create folders whenever they like. You would be chasing new folders forever. Use the blank file as a backup on hosts where you cannot change the server config, and add it to any folder a plugin creates for private data.
One thing that does not work: IndexIgnore *. That directive hides entries from a listing but leaves the listing page itself in place, as our test table shows. It still tells a scanner the folder is browsable.
Can a security plugin turn off directory indexing for me?
Several security plugins offer a “disable directory browsing” or “disable index views” switch. Under the hood they write the same Options -Indexes line into your root .htaccess. That is convenient if you never want to open a file manager, but it inherits every limit above:
- It fails with a 500 on hosts that block
Optionsoverrides, and the plugin may not tell you why. A user of All In One WP Security reported exactly that on the WordPress.org forums after switching on Disable Index Views. - It does nothing on Nginx or OpenLiteSpeed, where
.htaccessis ignored. - It belongs to the plugin. Deactivating or resetting the plugin can remove the line, and nothing warns you that listing is back.
Our view: write the line yourself, or better, set it in the server config. It is one line, and you will know where it lives the next time you troubleshoot.
Which method should you use?
Method | Works on | Survives plugin changes | Covers new folders | Best for |
|---|---|---|---|---|
Server config ( | Apache, Nginx | Yes | Yes | VPS and dedicated servers |
| Apache, LiteSpeed Enterprise, if | Yes | Yes | Shared hosting |
| Same as above | Yes | Yes, under uploads | Minimal-change fix |
Blank | Any server | Yes | No | Backup layer, private plugin folders |
Security plugin toggle | Apache, LiteSpeed Enterprise | No | Yes | Owners who avoid file editing |
How do I get “Index of” pages out of Google?
Switch the listing off first. Once those URLs answer 403, Google drops them from results as it recrawls them, which can take days or weeks. For anything you want gone faster, such as a listing that exposed customer files, use the Temporary Removals tab in Search Console. Google’s help page says a removal request blocks the URL from results for about six months, which is plenty of time for the recrawl to see the 403.
Do not try to fix this with robots.txt. Google’s own robots.txt introduction says robots.txt “is not a mechanism for keeping a web page out of Google”. A disallow rule stops crawling, so Google may never see the 403, and the old listing can stay indexed. It also does nothing to stop a person or a scraper loading the folder directly. If you are editing robots.txt for other reasons, our sibling guide on overwriting the WordPress robots.txt file walks through it.
Common mistakes people report
These come up again and again in WordPress support forums. Each item links to a real thread or vendor page, with the date it was posted or last updated. Checked on 18 November 2026.
- Putting the line inside the WordPress block. One site owner added
Options -Indexesbetween the# BEGIN WordPressmarkers and found it gone a few weeks later, after permalinks were saved. WordPress.org forum, March 2021. - A 500 error from a plugin’s own .htaccess. WP Super Cache rewrote a cache-folder
.htaccesscontainingOptions -Indexesevery time the Advanced tab was opened, and the host rejected it with a 500. WordPress.org forum, March 2017. WP Rocket documents the same “Options not allowed here” error for its cache folder (WP Rocket docs, updated June 2022). - Copying “Options All -Indexes”. A user enabled a plugin’s “Indexes” suggestion, which wrote
Options All -Indexes, and got locked out of both the site and the admin with a 403 until the line was removed over SSH. WordPress.org forum, last updated August 2016.Allswitches on every option except MultiViews, including CGI execution, and Apache’s docs call mixing signed and unsigned options invalid. Use plainOptions -Indexes. - Using robots.txt to hide uploaded files. A form-plugin user found uploaded files in Google and added a robots.txt rule, then noticed it did not stop direct access. The plugin author confirmed that everything in
wp-content/uploadsis public. WordPress.org forum, March 2019. A Moz Q&A thread on sudden indexing of “Index of /wp-content/uploads/” reached the same answer: switch off the listing, since robots.txt only stops crawling. - Expecting .htaccess to work on Nginx. Nginx never reads
.htaccess, and listings only appear there whenautoindex on;is set somewhere, often through a control panel box. Plesk forum, November 2016.
Frequently asked questions
Will turning off directory indexing break images or downloads?
No. It only changes what happens when someone requests a folder with no index file. Direct links to files, such as /wp-content/uploads/2026/11/photo.jpg, keep working exactly as before. In our test the uploads folder returned 403 while the image inside it still loaded.
Does disabling directory browsing affect SEO?
Not in a bad way. Folder listings are thin pages nobody should land on from search. Turning them off removes junk URLs from the index over time. Your posts, pages and media URLs are untouched.
Do I need this on managed WordPress hosting?
Usually not, but check anyway. Most managed hosts disable listings at server level. The curl check takes ten seconds and tells you for certain. If it shows 403 everywhere, leave your .htaccess alone.
Does Options -Indexes stop people downloading files from uploads?
No. It hides the list, not the files. Anyone with the exact URL can still download a file. For files that must stay private, store them outside the web root or serve them through a script that checks the visitor’s login. Correct file permissions are a separate layer and do not change this either, since the web server must be able to read uploads to serve them.
I see a 403 on my uploads folder now. Is something broken?
No, that 403 is the goal. It means the folder exists and the server refuses to list it. If a whole page or the homepage returns 403, that is different: check for an Options line that replaced rather than removed options, and restore your backup .htaccess.
A two-minute checklist
- Run the curl loop against
uploads, a dated uploads folder,wp-includes/js/and one plugin folder. - If any return “Index of”, fix it in the server config if you can, or add
Options -Indexesabove the WordPress block in.htaccess. - On a 500, remove the line and ask the host to allow
Optionsoverrides or switch listing off for you. - On Nginx, grep for
autoindex onand remove it. - Re-run the check until every folder answers 403.
- Search Google for
site:yourdomain intitle:"index of"and file removals for anything sensitive.
Directory listing is one of the items in our five-minute WordPress security audit. If this check failed, the others on that list are worth the same few minutes.
Plugins we build and run
We maintain these ourselves, which is why we can support them on your site.
- BuddyNextThe self-hosted community engine for WordPress
- BuddyXFree community theme, Pro when you outgrow it
- ReignPremium community theme. Add pieces, build anything
- JetonomyCommunity forum and Q&A for WordPress
- EventonomyEvents and RSVPs for WordPress communities
- LearnomyCourses and learning communities on WordPress
- ListoraDirectories and listings your members can browse
- SnipShareCode sharing built for developer communities
- WB Ad ManagerAd placements that turn traffic into revenue
- WP Career BoardA job board your community actually uses
- WP Sell ServicesSell services with offers, orders, and payouts
- MediaVersePhotos, video, and media albums for members
- WB GamificationPoints, badges, and rewards that keep members active
- Product RoadmapPublic roadmaps with voting your users trust


