How to protect image directory?

Hi,

My images folder currently lists all the images inside when I go to mysite.com/images. I want to prohibit direct access to the images folder. How can I have something like http://www.sitepoint.com/forums/images/ or http://w3schools.com/images/ ?

Thanks.

Just put a file inside the images folder called index.html. It can be blank, or can have a message such as “Access Denied”. But with that file in there, it’s not possible to view the contents of the folder in the way you described.

Ralph, thanks for the quick answer. I have many subfolders in the images folder and it seems that I need to put an empty index.html file in every subfolder. Isn’t there a better approach?

also, if you are in a linux server you can prevent directory browsing via .htaccess

Options All -Indexes

You mean Apache…nothing to do with Linux.

yes. Also, if it is nothing to do with linux you can try to include .htaccess files in Apache and Windows. Come here and tell me the results of yout attempt.

It doesn’t take long to do that, though. I just do it as a standard thing every time I create a folder.

Yes, this worked, thanks.

Ralph, even if it doesn’t take any time I would always prefer a non-manual solution.

Works just fine on Windows. It works because it has nothing todo with the operating system Apache is running on.