How to Allow access only for IP range using htaccess (security tutorial)
The idea is to block access from all IPs, exept the range for yours, basically you cannot allow a range of IPs on the .htaccess using the "allow from", but you can emulate it with multiple CIDR networks IPs format.
Bellow is a .htaccess example to allow access only to IP range from 10.10.10.0 to 10.10.10.255, to specific folder
Deny from All
# Allow only for range 10.10.10.0 to 10.10.10.255 (the 24 in CIDR mean 255)
Allow from 10.10.10.0/24
Change the red ip address with your ip range, and copy the above lines to a .htaccess on the root of the folder you want to protect, to check your ip just write "my ip" on google search.
# To Allow all ips from 0.0.0.0 - 0.255.255.255.255 by fixing the first number.
Allow from 0.0.0.0/8
# Another one : 18.104.22.168 - 22.214.171.124
Allow from 126.96.36.199/23
# Allow small range : 188.8.131.52 - 184.108.40.206
Allow from 220.127.116.11/30
Thanks, and if you have any question leave a comment.
If you like this article, please share it on facebook, tweet it and +1 it to spread it :) !
How to Allow access only for IP range using htaccess (security tutorial) Reviewed by Maherr Live on Sunday, May 05, 2013 Rating: