Limit Access to Local Area Network Using htaccess

  • Avinash
  • 5
  • Jul 21, 2011
  • Tips & Tricks

Recently I have posted several articles describing the use of the .htaccess file.

In this post I will explain how can we limit the access of the website to Local Area Network only.

You can specify the IP range for which you want to allow the access.

You need to place the below code in .htaccess file.

# limit access to local area network only order deny,allow deny from all allow from # This will limit the access only from to
# limit access to local area network only
 order deny,allow
 deny from all
 allow from
# This will limit the access only from to

Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by:

  • webdevelopers

    Code is better to understood.

  • Kris

    How do the rules work – when it says deny from all, does it not match all requests including 192… Given my background in ASP.NET, I am curious how it works as the rules are exactly the opposite in ASP.NET. Also is it possible to use NTLM based authentication with Apache in a Windows environment.

    • Avinash

      Yes first we have declared that “deny from all” and then after we have also declared the “allow from”,

      How to assign permission is based on this sentence “order deny,allow”.

  • Luke

    Nice that will be useful to keep some docs secured.

    • Avinash

      Thanks Luke…