Home HTACCESS Directory ON-OFF using Htaccess

Directory ON-OFF using Htaccess

If you have no index or default page in a specific directory, a visitor may be served with a full list of files that the directory contains. This is usually not a good idea as it could pose a security risk. To counter this effect, add this to the htaccess file.

Options -Indexes

Another way to turn off an index listing is :

IndexIgnore *

That states the directory should not list “all” files. The star symbolizes all files.
Just the opposite situation may arise too. If you really do want directory listing to happen but the main server settings have it turned off, you may turn it on like this :

Options +Indexes

To have a directory listing turned on BUT have no image files showing :

IndexIgnore *.gif *.jpg

So any files that do not have a GIF or JPG extension on them would be allowed to be listed.

You may also like

Leave a Comment