Sunday, July 17, 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 192.168.0.1 IP user.
order allow,deny
deny from 192.168.0.1
allow from all
# Restrict an IP range from 192.168.0.0 to 192.168.0.10
order deny,allow
deny from 192.168.0.0/10
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.


0 comments:

Post a Comment

Any Questions or Suggestions ?

About

Professional & Experienced Freelance Developer From India, Technologist, Software Engineer, internet marketer and Open Sources Developer with experience in Finance, Telecoms and the Media. Contact Me for freelancing projects.

Enter your email address:

Delivered by FeedBurner