Sunday, May 4, 2008

IP based restriction in Apache

We can restrict the access to any particular URL and its sub urls by modifying apache's Config. file

For example : if we have to restrict admin section of our site to be browsable only by few specified IP then in apache's Config. file we just have to add

<\Location /admin>
Order Allow,Deny
Allow from
( Please remove the '\' before open and close Location tag's )

This is only allow requests coming from , requests from any other IP will get


You don't have permission to access /admin on this server.

This restriction also applies to the sub-urls like admin/user_list etc....

Suppose we have to provide access to more than one IP, then we just have to provide the different IP's separated by a space between them.


Allow from ..........

The same can be applied for rejecting a request from a specified IP

Order Allow,Deny
Deny from

No comments: