My site is showing a list of all my files! How do I control directory indexes?

Question:

My site is showing a listing of all my files. Anyone who comes to my website can see everything! Help!

Answer:

The directory index is showing because you have no index.html file. Anytime there is no index.html (or index.php, index.htm, etc.) the server will show the default index that it creates on the fly.

You can also control the automatic creation of indexes by performing the following steps :

Create (or edit your existing) .htaccess file and put it in the topmost directory that you want to control. To enable / disable for your whole site, put it in your www directory.

To disable directory listings, add the line :

Options -Indexes

To enable them, add the line :

Options +Indexes

If your site still does not list the directory after enabling and you get the error :

“Forbidden You don’t have permission to access / on this server.”

make sure the read privilege is set for the directory you have the .htaccess file in.

Leave a Reply

Your email address will not be published. Required fields are marked *