Article
Directory listing: what an "Index of /" page leaks (and how to switch it off)
Published 2026-11-18
Directory listing: what an "Index of /" page leaks (and how to switch it off)
If you have ever typed a folder path into a browser and gotten a page titled "Index of /uploads" with a tidy list of every file inside, you have seen directory listing. The page looks harmless, almost boring. That is exactly why it survives on servers for years: nobody looks at it, so nobody flags it.
Web servers do not list folders out of malice. When a request ends in a slash and there is no index file (index.html, index.php) to serve, some servers fill the gap with a generated listing instead of an error. The behaviour is a configuration choice, and on Apache it has historically been close to the default, which is why it shows up on shared hosting constantly. Security scanners report it as CWE-548, and while it is rated low severity on its own, the files it exposes decide the real impact.
What actually leaks through a listing
The listing itself only shows names, sizes, and dates. The damage comes from what those names reveal:
Backups and dumps. The classic finds are .sql dumps, .zip archives of the site, and .bak copies of config files that someone put "temporarily" into the web root. A wp-config.php.bak sitting next to the original is readable by anyone who guesses its name, and listing hands them the name. This is the scenario that turns a low-severity finding into a full compromise.
Upload folders. On WordPress sites /wp-content/uploads/ is the interesting one. WordPress creates index.php files in some folders but not in the uploads/YYYY/MM subfolders it generates every month, so those months can be browsable while the parent looks fine. If someone ever uploaded a file they should not have, listing makes it findable years later.
Structure reconnaissance. A listing answers questions an attacker would otherwise have to guess: which third-party libraries you use, which versions, whether there is a .git directory in the web root (a .git folder under the docroot means the whole repository history is one URL away), where your admin tools live. File names are a map of the application.
Search engine memory. Listings get indexed. Even after you switch listing off, old pages can persist in results, and there are well-known Google dorks like intitle:"index of" site:example.com that specifically hunt for them. Turning the listing off today does not recall the copies.
Check whether yours is on
The manual test takes a minute. Open these paths in a browser where you are not logged in, or from a private window:
https://example.com/wp-content/
https://example.com/wp-content/uploads/
https://example.com/wp-includes/
https://example.com/assets/
https://example.com/files/
What you want to see is a 403 Forbidden, or a blank white page (WordPress drops an empty index.php into some folders for exactly this reason). What you do not want is a list of file names with sizes and dates. Test several folders, including the deep ones: the parent can behave while a month-folder under uploads does not.
From the command line the same check fits into a loop:
for p in / /assets/ /uploads/ /wp-content/ /wp-content/uploads/; do
curl -sk -o /dev/null -w "%{http_code} $p\n" "https://example.com$p"
done
A 403 or a 301 to an index page is fine. A 200 on a path you know has no index file deserves a closer look. This is also the kind of check an automated scan covers across the whole site at once, which is the more honest option if you do not know all the folders you have accumulated over the years.
How to switch it off, per server
Apache. Listing is controlled by the Indexes option, served by mod_autoindex. Remove it:
Options -Indexes
Put that in the .htaccess file in your web root, or in the <Directory> block for your docroot in the virtual host. If you use .htaccess, the host must allow overrides (AllowOverride Options or All); if it does not, Apache answers with a 500 error, which at least tells you immediately instead of failing silently. Then validate and reload:
apachectl configtest && apachectl graceful
One detail trips people up more than anything else: an Options +Indexes line in some subfolder's .htaccess re-enables listing for that folder and overrides your root setting. Search the whole docroot for it:
grep -rn --include=.htaccess "Indexes" /var/www/
nginx. Here the news is better: autoindex is off by default, and a stock nginx does not list directories at all. If you see a listing, someone turned it on at some point, usually while debugging file serving and never turned it back off. Find it and remove it:
grep -rn "autoindex" /etc/nginx/
Change any autoindex on; to autoindex off;, then:
nginx -t && systemctl reload nginx
A common trap on managed servers: nginx sits in front of Apache as a reverse proxy. The listing you see is generated by the Apache behind it, so fixing the nginx layer changes nothing. Fix it where the "Index of" page is actually generated.
IIS. In IIS Manager, open the site, select Directory Browsing, and choose Disable in the Actions panel.
cPanel. Advanced → Indexes, select public_html, choose No Indexing, save. Subfolders set to Inherit follow the parent; check that no subfolder carries its own "show file names" setting.
The index.php trick. When you cannot touch server config, dropping an empty index.php into each browsable folder works, because any server serves an existing index file before falling back to a listing. It is a legitimate fallback but a fragile one: you have to remember every new folder, including the year/month folders WordPress creates automatically. A server-level rule does not have that maintenance burden.
Turning off listing is not restricting access
Here is the part worth being blunt about. Disabling listing hides the file names; it does not lock the files. Anything that was browsable is still directly reachable at its old URL, for anyone who already knows or guesses the name. So the cleanup has two parts, and skipping the second is how teams get surprised later:
- Switch listing off, everywhere, not just the one folder the report mentioned.
- Go through what was exposed and remove what never belonged on a public web server: database dumps, site archives,
.bakand.oldcopies of configs, anything with credentials in it.
If a dump or backup was listed for any length of time, assume it may have been downloaded. That means changing the passwords and API keys it contains, not deleting the file and moving on. Which files were exposed, and since when, is something your file dates in the old listing would have told you — another reason screenshots or logs of the finding are worth keeping before you fix it.
A short note on scale
The reason scanners keep reporting directory listing is that sites accumulate folders faster than anyone audits them. A five-year-old WordPress install with a dozen plugins, a few staging copies nobody removed, and a shared host that shipped Indexes enabled by default is not a rare profile. It is the median one. Listing is also one of the few misconfigurations that costs one config line to fix and zero ongoing effort to keep fixed, which puts it high on any list of things worth an hour this week.
If you want the whole picture rather than the folders you remembered to test, CheckWebSecurity scans the site from the outside and reports browsable directories alongside the other exposure findings, with plain-language explanations of what each one means. Start a free check.
Related: WordPress security scanning without plugins · How website security checks work