17 March 2010

To HIDE the Directory listing in the apache

How to disable directories from browsing or indexing to hide images, and other files from visitors. This give you total control of your web folders to block unwanted viewing using .htaccess files with Apache
Disable or Enable Directory Browsing or Indexing in .htaccess file

Browsing or indexing is an option that allows the contents of a directory to be displayed in the browser when the directory does not contain an index page.

For example, if you make an http call to a directory such as http://yourdomain.com/images/, it would list all the images in that directory without the need for an html page with links.

We will need to create a blank file called “.htaccess”. You can name it “htaccess.txt” while your editing it, then rename the file to “.htaccess” after the file is on your web server.
Disable Directory Browsing or Indexing

Type or copy and past the following line of text in to your blank file.
Note: I add the work “All” so that every folder in that directory follows the same rule.

Options All -Indexes
IndexIgnore *.gif *.jpg *.png *.swf

Enable Directory Browsing or Indexing

You can reactivate it by adding the following line to your .htaccess file:

Options +Indexes

Once this is added, the directory will fully index again.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home