How to allow access to file only to users with ip which are in a range of ip addresses?
For example file admin.php. and range from 0.0.0.0 to 188.8.131.52.
I need configure access to only ONE file not to directory.
The following would block acces to all scripts ending in “admin.php” :
<FilesMatch "admin\.php$"> Order deny,allow Deny from all Allow from 10.0.0.0/24 </FilesMatch>
The following would ONLY block admin.php :
<Files "admin.php"> Order deny,allow Deny from all Allow from 10.0.0.0/24 </Files>
For more information refer to the apache docs on Configuration Sections.
check the man page of the Allow Directive
Order Deny,Allow Deny from all Allow from 10.1.0.0/255.255.0.0
A partial IP address
Allow from 10.1 Allow from 10 172.20 192.168.2
The first 1 to 3 bytes of an IP address, for subnet restriction.
A network/netmask pair
Allow from 10.1.0.0/255.255.0.0
A network a.b.c.d, and a netmask w.x.y.z. For more fine-grained subnet restriction.
A network/nnn CIDR specification
Allow from 10.1.0.0/16
Similar to the previous case, except the netmask consists of nnn high-order 1 bits.
You cannot match an IP range with allow, but you can emulate it with a CIDR notation:
Order allow,deny # 0.0.0.0 - 0.255.255.255.255 Allow from 0.0.0.0/8 # 184.108.40.206 - 220.127.116.11 Allow from 18.104.22.168/15 # 22.214.171.124 - 126.96.36.199 Allow from 188.8.131.52/23 # 184.108.40.206 - 220.127.116.11 Allow from 18.104.22.168/24 # 22.214.171.124 - 126.96.36.199 Allow from 188.8.131.52/30 # 184.108.40.206 Allow from 220.127.116.11
Just do this for a single IP:
<Limit GET POST> order deny,allow deny from all allow from 18.104.22.168 </Limit>
If you want to do it for a range like 10.x.x.x, then do this:
<Limit GET POST> order allow,deny allow from 10 deny from all </LIMIT>
If you are using WordPress, then the Best and Simplest method is to install the plugin – LionScripts : WordPress IP Blocker from their website http://www.lionscripts.com/ip-address-blocker
Their Professional version has much more features like country blocking and IP range blocking, bulk csv uploading etc.
if you to provide a wildcard 0.0.255.255
Order allow,deny # 22.214.171.124 - 126.96.36.199 Allow from 188.8.131.52/16
This will give a range from 184.108.40.206 – 220.127.116.11
you can also check here
Order Deny,Allow Deny from all Allow from 311.311.311 322.322.322.322
See answer here