Subscribe:

Ads 468x60px

Pages

Wednesday, August 10, 2011

Prevent Directory Listing using .htaccess

Directory Listing
Directory listing:
In most of the website contains “images” folder inside the root folder. If we type “www.example.com/images” in the browser and it shows the listing of the files in the browser like the image above which means that directory listing is allowed on that web server. It’s better not to show the files inside the directory of the web sever for the security purpose.

To prevent directory listing
Put the any one of following code into the .htaccess file
Options -Indexes

or

IndexIgnore *


If you don’t want to list “.jpp , .gif and .zip” and you don’t care about listing other files of that directory then you can out the following code inside .htaccess.
IndexIgnore *.gif *.jpg *.zip

If your want to allow directory listing then you can add the following code in the .htaccess file to allow the directory listing.
Options +Indexes

0 comments:

Post a Comment