Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

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 like images,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 accessing images 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.

Enter your email address:
 
Feel free to ask any question. Just leave your comment below and we will answer your comment with in 24 hours.
Share:

4 Comments

  • How to restrict users from accessing files & directory level(Protect directory) using .htaccess | Programming Facts…

    I have to restrict or deny users from accessing files and folders(images) of my web application directly by entering URL. We can restrict users from accessing files,folders and subfolders by using .htaccess(Hyper Text Files)….

  • Hi there, just became aware of your blog through Google,
    and found that it is truly informative. I am gonna watch out
    for brussels. I’ll be grateful if you continue this in future. Numerous people will be benefited from your writing. Cheers!

  • Its like you read my mind! You seem to know a lot about this,
    like you wrote the book in it or something. I think that
    you can do with some pics to drive the message home a
    bit, but instead of that, this is wonderful blog.
    A great read. I’ll definitely be back.

  • Link exchange is nothing else however it is simply placing the
    other person’s blog link on your page at suitable place and other person will also do similar in favor of you.

Leave a Reply to Basic: Journey Cancel reply

Your email address will not be published.