How to disable directory listing in apache

This post was written by Mahi-Bhat on January 27, 2009
Posted Under: Apache

In Apache HTTPD server normally when you have no index or default page in a directory, a visitor may be served with a full list of files in that directory. To stop default directory listing follow any one of the steps given below

1. Open/Create the .htaccess file and add

Options -Indexes

OR

2.Open the httpd.conf(apache configuration) file and look for the section

<Directory /var/www/html>
…..
Options Indexes FollowSymLinks
…..
</Directory>

change to

<Directory /var/www/html>
…..
Options -Indexes FollowSymLinks
…..
</Directory>

then restart your Apache server. That is it, directory listing will be disabled now.
Note :- here ‘/var/www/html’ is the document root directory.

Reader Comments

thats a nice post Bhat..

#1 
Written By Sai Krishna on July 6th, 2009 @ 12:43 PM

Add a Comment

required, use real name
required, will not be published
optional, your blog address

Previose Post: