ID #53

How do I stop people from getting directory listings when I dont have an index page?

Applies to: Grid System

If a URL which maps to a directory is requested, and the there is no DirectoryIndex (e.g., index.html) in that directory, then the server by default will return a formatted listing of the contents of that directory.

To turn these directory listings off, simply add to (or create) an .htaccess file in the directory you want to protect and insert:
Options -Indexes

If you are just trying to change what the default index page will be called, see this other FAQ.

Last update: 2010-09-29 16:36
Author: FAQ Admin
Revision: 1.2

Digg it! Share on Facebook Print this record Send FAQ to a friend Show this as PDF file
Please rate this FAQ:

Average rating: 4 (9 Votes)

completely useless 1 2 3 4 5 most valuable

You can comment this FAQ

Comment of Anonymous:
All you do is create a file named: .htaccess

Inside that file you put 1 line:

Options -Indexes

You upload the file to your home directory with your FTP program and then no more directory listings will get shown.
Added at: 2004-03-29 10:38

Comment of Anonymous:
You could always just create a "dummy" index.html file with no content:

No Access Allowed
No Access Allowed

Added at: 2007-09-07 16:00

Comment of Anonymous:
Just adding a .htaccess file may not always work. The apache configuration settings have to be such that AllowOverride is set to include the 'Indexes' option. Normally, the default configuration is to "AllowOverride All" which should allow the .htaccess file to change directory listing options. If the .htaccess file does not work for you, you can either modify your apache configuration to allow it, or ask your admin to change it for you.

The index.html file is a good and easy way to get around this. If your system supports php and index.php files, you can make a simple php index.php as:

This will always redirect someone who is trying to get a listing of the directory contents. This is my preferred method.
Added at: 2008-07-01 13:56

Comment of Anonymous:
Before using .htaccess, please check your server configuration, support .htaccess or not. If not support, you can using index.html but the problem if many folders have to protect, so best way is using
Options -Indexes


Added at: 2009-01-23 08:21

Comment of Dackie:
Why create an .htaccess? You can modify the httpd.conf directly and find the line which says
"Option ... Indexes ..."

Either remove the word "Indexes" or have it preceeded with "-" to be like this:
"Option ... -Indexes ..."

Added at: 2010-07-23 09:40