RSS
people

Deny directory listing using .htaccess

When you do not have an index.html (or index.php) in your folder, then people can see the listing of all the files by typing the URL of that folder. So, if the server does not deny it by default, an user can see the content of the folder.

We can use htaccess file to prevent it.

Step 1.
Create a file name .htaccess in your folder. (If you already have one, open it and edit)
Step 2.
To ignore all file listing, Write: IndexIgnore *
To ignore special file listings, Write: IndexIgnore *.zip *.gif
(The line above will list all files except the files having zip and gif as extension.

Sometimes, the opposite is required. That means, server denies the directory listing by default but you want to enable it for some reason. This can be achieved using htaccess as well.

Step 1.
Create a file name .htaccess in your folder. (If you already have one, open it and edit)
Step 2.
Write: Options +Indexes

Leave a Reply