How to Block a Country by IP Address in Apache

apache-2.2blockgeoip

I have a website that needs to block a particular country based on IP address. I am more than aware that IP-based blocking is not a foolproof method for blocking visitors, but it is a necessary step in the right direction.

Since I'm using PHP, what I would do is use a GeoIP database like geoplugin.net. However, I'm curious to know if there's a better way of doing this.

The website is on a shared webserver (I don't have root access) and it is running Apache on centOS. I guess my question is "can an .htaccess file be configured to block by IP using an external source to lookup IP addresses."

Best Answer

http://www.blockacountry.com

Use cautiously...I'm sure there are plenty of people on here that think you are doing the wrong thing by blocking whole countries.