Tuesday, April 27, 2010

Prevent Directory Listing using .htaccess

How to prevent directory listing ?
Put the any one of following code into the .htaccess file
Options -Indexes
or
IndexIgnore *
If you place that .htaccess file in the root folder then direcotry listing is prevented of the sub-folder as well. And if you place the .htaccess file inside the “images” folder then directory listing are prevented of that particular directory only.
Let’s suppose that 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
Finally, If your server is setup with preventing directory listing then you can add the following code in the .htaccess file to allow the directory listing.
Options +Indexes

No comments:

Post a Comment

 

Followers