How to Not Allow Directory Listings

Some web hosts allow a directories contents to be displayed if there is no index file contained within that directory. This could cause a serious problem if that directory contained any sort of sensitive materials. If your hosting account is on a Unix or Linux server this problem is fairly easy to eliminate using a file called .htaccess. On my Windows PC I create a
new text document called htaccess.txt and within that file I put the following line:

Options -Indexes

That tells the webserver not to allow directory listings. I then upload the htaccess.txt file into the root folder for my domain and go in through a web based file browser or shell and rename the file to .htaccess . Windows will not let a file not have a name and just an extension so this is the simplest way to do it.

Some webmasters will also create an index page for every directory but if there are alot of directories this could take time. Using the htaccess file protects every directory in the site.

This entry was written by and posted on Friday, March 14th, 2008 and is filed under Hosting.
Tags: ,
Follow any responses to this entry through the RSS 2.0 feed.