Put the any one of following code into the .htaccess file.

Options -Indexes
IndexIgnore *

If you place that .htaccess file in the root folder then directory 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

Leave a Reply

Your email address will not be published.