View Full Version : How can I forbid access to folder(s)?

03-19-2010, 02:03 AM
I'd like to prevent public access to a particular folder on my web site. For example, the image folder. If someone tries to gain access to a particular folder, I'd like them to see an Access Denied page. What sort of coding magic do I need to use here.
Thanks for any suggestions

03-19-2010, 02:18 AM
if you domt want viewers to see what image files you want you coluld upload a blank index.html file. if you wanrt to restrict access with a password you can use .htaccess which may be featured on your hosting control panel
otherwise use php or the like to do it

03-19-2010, 04:34 PM
you could simply drop an index.htm in the directory to stop users navigating the directory. You could do this with a .htaccess file as well of course which is a better way


03-21-2010, 12:25 AM
Thanks for these suggestions. I'll try each of these and let you know how it goes.

03-24-2010, 10:39 PM
Thanks again. I've uploaded a blank index.html file in the directories I want to screen from view. This basically does what I want.
My host, Yahoo!, does not allow uploading of .htaccess files to my account. They have their own method for password protection in their Web Hosting Control Panel. I'm going to try this in the future.

03-25-2010, 01:11 AM
you could put a refresh metatag in these index files to bounce them out to the home page if they try to navigate to the directory

<meta http-equiv="refresh" content="0;url=http://yourdomain.com">

03-25-2010, 02:52 AM
davidj: Very, very, extremely, cool. -Thanks a lot!

04-06-2010, 03:36 PM
If you do this from the command line on a Linux/UNIX operating system, you can do:

chmod 000

This will make the folder no access.

04-06-2010, 08:17 PM
you should have directory browsing off on all your folders for security measures.

Goes to show how great Yahoo's hosting really is if this isn't set to default.

04-07-2010, 03:30 PM
Yahoo Hosting. Ah I see. Yes, they are meant to serve a general market and thus unix/linux commands don't apply.