June 30, 2006

Enable/Disable directory listings using .htaccess

by @ 9:56 pm. Filed under Linux Hosting
Disabling directory listings using .htaccess

By default when accessing any directory which does not contain an index file (ex: http://yourdomain.com/images/) a directory listing will be shown displaying a list of the files in that folder. Simply adding a blank/0 byte text file named “index.html” will prevent this directory list from being displayed, however another way to disable directory listings by adding the following line to the .htaccess file in your public_html folder of your web hosting account :Options -IndexesThat’s it, with this line in place folders which do not contain index files will no longer show the default directory list.

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
If you want the directory contents to be listed, but only if they were HTML pages and not images. Adding the following line to the .htaccess file. IndexIgnore *.gif *.jpg This would return a list of all files not ending in .jpg or .gif, but would still list .txt, .html, etc .

Leave a Reply

You must be logged in to post a comment.

RESELLER HOSTING | DEDICATED SERVER | PREMIUM HOSTING | VPS HOSTING

Micfo Hosting

Micfo International LLC Leading the hosting Industry with Cheap and Affordable Linux Web Hosting Packages.

internal links:

categories:

archives:

Services:

Micfo Hosting

Micfo, delivering the best cpanel web hosting with maximum reliability is our exclusive focus.
Micfo International LLC

search blog:

TOP 10 POSTS:

Pages:

General Links:

Syndicate

other:

35 queries. 0.100 seconds