A knowledge base for new webmasters

How to prevent users from listing files in your directories

Many web servers are configured to prevent visitors from listing files in directories that don't contain an index file (e.g., index.php, index.html). Here's what you can do if yours isn't:

  1. Open a text editor and type in the line below:
    Options All -Indexes
  2. Save the file as .htaccess.
  3. Upload .htaccess into the folder on your server where your website's home page is located.

From on now on, your server will display a "403 Forbidden" error when a visitor tries to access any directory that doesn't contain an index file.