.htaccess – Directory listing

Consider you have a bunch of files in your directory called uploads, it may have zip files, jpg files, png files, pdf files, doc files and so on. In such case when someone enters the path in the browser ex: http://www.geeks.gallery/uploads/, the entire list of files gets listed. So one can easily access your files. In certain situation, you may have to avoid listing those important files for others.

In order to deny directory listing, you can simply add a line in your .htaccess file.

Options -Indexes

You will get a result as


If in case, you have to enable the listing of files in the directory, do this

Options +Indexes

If you don’t wish the user to see Access Denied message, and also you wish to hide the files from listing, in that case you can use the following code

IndexIgnore *

The result will be


If you want only a single zip file to be hidden, we can also do that.To do so

IndexIgnore filename.zip

And we can hide all zip files in a directory by

IndexIgnore *.zip

We can also hide zip,pdf and doc files and show other formats of file at a time.

IndexIgnore *.zip *.doc *.pdf

Thanks for Reading.

Follow me


Web Developer at Energy Alternatives India
I'm interested in developing Web applications andkeen on learning new technologies.

View Nagarajan's Profile
Follow me

Latest posts by Nagarajan (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *

займ на карту онлайн круглосуточно