πŸ“„
Webhosting

Disable directory listing: how to prevent it

πŸ“… 9 October 2026 ✏️ 9 October 2026 ⏱ 4 min leestijd

Directory listing exposes your website’s files in the browser. Learn how to spot it, why it’s risky, and how to disable it.

Ever typed a URL without a filename and suddenly saw a bare list of files and folders instead of your website? Then you’re dealing with directory listing. This happens when a folder doesn’t contain an index file (such as index.html or index.php) and the server is set by default to display the folder contents instead. This is a security risk, because visitors can find files that weren’t meant to be publicly visible. You can easily disable it via your .htaccess file or the settings in Plesk.

What exactly is directory listing?

Every folder on your web server can contain an index file that is automatically loaded when someone visits the folder. If that file is missing, the server sometimes falls back to showing an overview of all files and subfolders in that location. This is called directory listing or directory browsing. You then see file names, sizes, and creation dates directly in the browser.

This often occurs in folders such as /uploads/, /images/, or /backup/, where no index file has been created but which do contain files that aren’t meant to be viewed individually.

Why it’s a risk

Directory listing isn’t a hack in itself, but it does make it easier for malicious actors to investigate your website. Think of:

  • Insight into file names of scripts, plugins, or configuration files
  • Access to backup files accidentally stored in a public folder
  • Visibility of software version numbers, which can be used to search for known vulnerabilities
  • Access to documents that aren’t linked on the site but are still publicly accessible
πŸ’‘ Tip: Combine disabling directory listing with a good firewall setting and regular checks of your folder structure for extra protection.

Disabling directory listing

There are several ways to tackle this, depending on how your hosting is set up.

1

Via .htaccess

Add the line Options -Indexes to the .htaccess file in your website’s root folder. This works on Apache and LiteSpeed servers and is the fastest solution without needing to install anything.

2

Add an empty index file

Place an empty file named index.html or index.php in every sensitive folder. The server then loads this empty file instead of showing the folder contents, even if .htaccess doesn’t work or your hosting ignores that file.

3

Check the setting in Plesk

In Plesk, go to Websites & Domains, open your hosting settings, and check under the Apache and nginx settings whether the option for directory indexing is turned off. Here you can configure this per domain without manually editing files.

4

WordPress-specific

For WordPress, the default .htaccess usually doesn’t add this rule automatically. Check this manually, especially after a migration or theme reinstallation.

Folder without indexFile listvisibleSecure

Without an index file, the server displays the folder contents; with the right setting, it stays hidden.

Checking if it worked

After making the change, open a folder URL of your website directly in the browser, for example yourdomain.com/uploads/. If you now see an error message (403 Forbidden) or your own website instead of a file list, it’s configured correctly.

Also check other sensitive folders such as backup locations, temporary export folders from plugins, and log files. It’s smart to check this periodically, especially after installing new plugins or themes that create their own folders.

πŸ’‘ Tip: If you get stuck adjusting .htaccess or server settings, Tandata’s support team is happy to help via ticket, WhatsApp, or email, day and night.

Frequently Asked Questions

Is directory listing the same as a hack?

No, it’s a server setting that can be enabled by default. It’s not an attack, but it is a risk because it exposes information you’d rather keep hidden.

Does Options -Indexes work on every hosting?

This works on Apache and LiteSpeed servers with .htaccess support. For other server configurations, such as pure nginx, you configure this through the server settings instead of .htaccess.

Do I need to set this up for every folder separately?

No, a rule in your website’s root folder usually applies to all subfolders, unless a subfolder has its own .htaccess file that overrides it.

Can I combine this with other security measures?

Definitely. Think of limiting file permissions, keeping sensitive files out of public folders, and setting up a firewall. Also check out our web hosting with default security settings.

Conclusion

Directory listing may seem harmless, but it gives visitors unwanted insight into your file structure. With a simple rule in your .htaccess file or a setting in Plesk, you can disable it quickly and permanently. Running into issues when switching to hosting with stricter default settings? Check out the options to switch to Tandata.

View web hosting β†’

Was dit artikel nuttig?