Due to some reasons, some webmasters may want to block the traffic from one country. It's very easy to do it with the .htaccess file of the Apache. The following is the basic grammar.
order allow,deny
allow from all
# specific IP address
deny from 123.123.123.123
# deny a range: 123.123.0.0 - 123.123.255.255
deny from 123.123.0.0/16
# the whole class: 123.0.0.0 - 123.255.255.255
deny from 123.0.0.0/8
# shorthand for previous
deny from 123
Like the above, just change the IP range to the speific range and add to your .htaccess file. Then you can block a country. The most complex thing is to get the up-to-date IP range of the specific country. I just got a result from Google that who provides the IP range of all countries for free. Please check the following link.
http://www.blockacountry.com/
So, now everything is solved.
If you want to know more about the .htaccess file. Please check .htaccess tips and tricks.
1 comment:
I personally prefer this one
http://www.ip2location.com/blockvisitorsbycountry.aspx
Their IP to Country Database is more up-to-date.
Just my personal opinion.
Post a Comment