Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use htaccess to restrict directory access by IP address?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 102
    Comment on it

    To restrict directory access by IP address you need to follow the steps given below:

    1. Create a file or open a file .htaccess(started with a dot) inside the directory that you want to protect.
    2. Add the code given below to the file:
    3. Order Deny,Allow
      Deny from all
      Allow from 127.0.0.1
      
      Instead of 127.0.0.1 in the above example you will write the IP address that you want to allow.
    4. You can also give partial IP address, for example: 127.0.0 allowing a range of addresses to access the directory or you can also give multiple IP addresses separated with comma.
    5. If comma separation is now working then you can allow multiple IP addresses to access the directory by adding the following lines as follows:
      Allow from 127.0.0.1
      Allow from 127.0.0.2

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: