Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My Website is hosted on a shared Apache server. How can I deny access to directory content pages so if someone goes to the address www.mywebsite.com/directory they don't see the following:

Index of /directory

Parent Directory

  • mycontent/
  • moreofmycontent/
share|improve this question
up vote 2 down vote accepted

There are two common ways to prevent directory listing under Apache:

  1. Create or edit the file called .htaccess in your web server's root directory and add the line:

    Options -Indexes

  2. Put blank index.html files in each subdirectory.

The first option is probably the best, unless you're distributing open source projects (like WordPress), when it's a good idea to use the blank index.html method to make sure subdirectories won't be listed by default for other people who download your project as well.

share|improve this answer
Perfect! Totally solved my problem. Using solution 1 for now, may have to use solution 2 at a later time if I use Wordpress or Drupal. Thanks for your help, Nick. – Jane Nov 19 '12 at 11:49
You're welcome. WordPress already uses the blank index.html files in all directories, so you shouldn't have to worry about it with WP. (I was one of the people who proposed they add them for security reasons.) I don't think Drupal uses blank index files, though. – Nick Nov 19 '12 at 11:55
While WordPress includes index.html files in it's folders to prevent browsing folders without an index. Other folders on your shared account my be browseable if you have not set the Options -Indexes in your .htaccess file. Hostmonster as of now doesn't set this in their htaccess file and all folders are browseable by default so be careful to double check all your folder or your root level htaccess file. – Anagio Nov 19 '12 at 13:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.