Allowing a few countries access, but redirecting all others

Is there any way of allowing just a few countries access, (USA, Mexico and Canada), and redirecting all other countries to another website address on the same website.

Must be 100% accurate, or at least 95%. Minimal load on the server. Free would be nice, but could pay 10-15 usd a month, if it was worth it.

The hosts have given me the info below, in case it’s of any help.

The following Perl modules are installed on the server:
Geo::IP 1.39
Geo::IPfree 1.110450
Geography::Countries 2009041301
I have installed Net_GeoIP PEAR module.

Any help much appreciated.


The most effective way to do this is with a perl script and the use of one of the geo modules already installed. I’ve done this with .htaccess, but unless you want to constantly tweak your script maintenance will be no fun.

Thanks Chris - I definitely wouldn’t want to keep tweaking it any more frequently than a few minutes once a month. Based on that, any more thoughts please?

I’m on a shared server.