Welcome, Guest. [ Log In ]
Question   How can I turn off the default directory listing in a directory?
Search KBase


Related Links:
· .htaccess files

Top 5 in this Area:
1. How do I use .htaccess files?
2. How can I turn off the default directory listing in a directory?
3. How do I block people coming from a certain website or URL from visiting my site or directory?
4. Can I use .htaccess files?
5. Various .htaccess samples and tutorials

 
How can I turn off the default directory listing in a directory?
Easy! There are two ways:

  1. You can just put a blank file named index.html in that directory.
  2. A "more correct" way is to put a file named .htaccess in that directory consisting of only this line:
    Options -indexes
    
    What's especially nice about doing it this way is all sub-directories of that directory will also get their directory listings turned off.

    You could then turn on indexes for one of those sub-directories just by making a .htaccess file in that directory with:

    Options +indexes
    

Last updated: Apr 25, 2002.

User Post (2005-12-06 01:36:57 by urhost)
Will this result in a 403 error? This is what I want to do, is this the best way to do it?
User Post (2004-08-20 09:12:40 by suture)
If you use Options +indexes how ca we create a custom HEADER and footer using README? This doesn't seem to be working on DH
User Post (2004-08-20 09:11:18 by suture)
You can also use .htaccess Redirections. Something like what I've shown below will redirect Users to your home page rather than displaying the Directory Listing.

Redirect /images http://www.mydomain/
User Post (2002-01-24 20:59:22 by bittondb)
you can also add
DirectoryIndex foo.html<br>on a new line and that'll become the new default index page