Prevent a Directory Listing with .htaccess

If you create a new directory (or folder) on your website, and do not put an “index.html” file in it, you may be surprised to find that your visitors can get a directory listing of all the files in that folder. For example, if you create a folder called “test“, you can see everything in that directory simply by typing “” in your browser. No password or anything is needed.

But you can configure your web server so that it does not show a directory listing by default.


  • Your Website Must Be on an Apache Web Server
  • Your Web Host Must Have Enabled .htaccess Server Overrides

Disable Indexing

Add the following line to your .htaccess file.

Options -Indexes

Make sure you hit the ENTER key (or RETURN key if you use a Mac) after entering the “Options -Indexes” words so that the file ends with a blank line.



Developer, Technology aficionado, Beer Lover and founder of Network. Who shares a keen interest about website development, health issues, cancer awareness and other fun stuff.

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

Most discussed