Thursday, May 2, 2013

How to turn off the default directory listing in a directory with htaccess file

Easy! There are two ways: You can just put a blank file named index.html in that directory. 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

Disqus Comments