Do you have a directory full of images or zip files that you do not want people to be able to browse through? Typically a server is setup to prevent directory listing, but sometimes they are not. If not, then you have to fix this yourself. Directory listing can compromise the security of your website, so it is very important that you control directory listing wisely.
There are two common ways of preventing directory listing:
- Placing a blank file named index.htm inside each directory that you would like to protect.
- Using .htaccess file.
Save the file and then upload it to the root directory of your website, after you have uploaded the file to the correct location just rename it to “.htaccess” and that is it, now no body can brows through your web directories.
In some cases the directory listing is disabled by default and to enable it you can use the following code:
[box type=”warning”] Always be careful and do not put any security compromising files in this directory.[/box]
The code mentioned above affects all directories, but if you want to disable directory listing for a specific directory you have to use the following code and then place the .htaccess file inside the directory you intened to restrict access to.
If you want users to be able to display all files inside a folder except images then you can use this:
IndexIgnore *.gif *.jpg
If you have any questions or would like me to discuss a certain topic please send me a message or simply just leave a comment below!