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

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.

Advertisements
Categories: .htaccess
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: