Basically, this PHP script utilizes MaxMind‘s free database for determining the country of an IP address.
Step 1) Get country-redirect.php
Step 2) Get the most recent IP-country database.
Step 3) Extract, then upload both files to the same directory.
Demo: You may see where it thinks you are from.
Once you download the script, go to the end of country-redirect.php to customize its output (here’s an example of how to make it redirect).
I’m not offering support for this script. The PHP coding wasn’t written entirely by me. I essentially combined a bunch of classes from MaxMind to make this work. I do not guarantee its functionality on your server. It should work for PHP4-5 at least.
The actual determining of the country is about 99.5% accurate. All AOL users are assumed to be from the United States.
In my case, I find this is helpful for affiliate offers that redirect based on a user’s country. This way (if you are an affiliate), you can select to which offers you’d like to send your international visitors.
Anyway, this should be helpful for providing more relevant content to all of your users.