Restrict online users to access folders

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
baby@qute
Forum Newbie
Posts: 4
Joined: Wed Jul 29, 2009 3:47 am

Restrict online users to access folders

Post by baby@qute »

Hi to all

Can some pls help me
I have build a website in php connected to myaql database
now i want to restrict the users to access the public_html folder in which i have many more folders like include,images, etc.. etc... i donot want the users online to directly access these folders

Thanks in Advances....
User avatar
turbolemon
Forum Commoner
Posts: 70
Joined: Tue Jul 14, 2009 6:45 am
Location: Preston, UK

Re: Restrict online users to access folders

Post by turbolemon »

In what way do you want to deny them access? If using apache, turn off directory listings using your apache .conf file, or .htaccess file within the directory (if allowed).

Code: Select all

<Directory /absolute/path/to/directory>
Options -Indexes
</Directory>
Do this for each directory to disable the directory listing, or to deny all access for users you could do something like this:

Code: Select all

<Directory /absolute/path/to/directory>
Order Deny,Allow
Deny from All
</Directory>
This will deny ALL requests for files which are located within that directory, including images embedded in pages and other content. This would be suitable for your includes directory but not so for images directory (unless you plan to supply the images using other means).

To use the above in .htaccess, you need to omit the <directory> tags surrounding the commands.

See http://httpd.apache.org/docs/1.3/mod/co ... #directory for more information.
Post Reply