Prevent Directory Listing

61 views
asked May 21, 2012 in Security by TheRock (920 points)
edited May 21, 2012 by TheRock
hello all

I have a website and I don’t want to allow users to view the files of a particular directory in such a direct way , and I want  prevent the listing of that directory. Does anyone know how can I do this?
Any help will be very much appreciated.
Thank you

2 Answers

0 like 0 dislike
answered May 21, 2012 by WebGuru (9,280 points)
Put the  following code into the .htaccess file
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.
0 like 0 dislike
answered May 21, 2012 by expert (14,380 points)
hi..
it could also be done by adding the following line to your .htaccess file
IndexIgnore *
for example if you don't want to list “.gif and .zip” and then you can put the following code inside .htaccess.
IndexIgnore *.gif  *.zip
...