Sunday, May 29, 2011

How to restrict users from accessing files & directory level(Protect directory) using .htaccess

Hello Friends,
Today i faced a situation where i have to restrict or deny users from accessing files and folders of my web application directly by entering URL in browser which contain very important contents likeimages,pdfs,docs,etc. For this what i need to do is to protect the files and folders(directory) which contains images,pdfs and docs. We can restrict users from accessing files,folders and subfolders by using.htaccess(Hyper Text Files).
Using .htaccess, you can restrict or deny access to individual files and folders. Below is the example how to restrict or deny users from accessingimages folder. Make a .htaccess files and upload it in images folder. So this will be effective only for images folder(not for whole site).
# This will restrict all users from accessing images folder directly from web.
deny from all
If you would like to ban only one IP or range of IP than look at the below rules.

# Restrict only IP user.
order allow,deny
deny from
allow from all
# Restrict an IP range from to
order deny,allow
deny from
allow from all
To know more about programming,JavaScript issues,jQuery,Expression Engine,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.


Post a Comment