Advertisement
Home arrow Web Development arrow Turning off the default directory listing
Turning off the default directory listing
Tuesday, 20 September 2005
Do you have a directory full of images or zips that you do not want people to be able to browse through? Typically a server is setup to prevent directory listing, but sometimes they are not. If not, become self-sufficient and fix it yourself:

IndexIgnore *

The * is a wildcard that matches all files, so if you stick that line into an htaccess file in your images directory, nothing in that directory will be allowed to be listed.

On the other hand, what if you did want the directory contents to be listed, but only if they were HTML pages and not images? Simple says I:

IndexIgnore *.gif *.jpg

This would return a list of all files not ending in .jpg or .gif, but would still list .txt, .html, etc

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

 





Reddit!Del.icio.us!Google!Live!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites!
 
< Prev   Next >