GeoRedirection script not working properly <p><br> I am developing a country specific website, for which I thought to have a geo redirection installed at my php server. The basic approach is to record the incoming IP address in <code>$_SERVER['REMOTE_ADDR']</code> and then use a geolocation database to convert that into country information. I did go with Maxmind geolocation service. The final script that I came through with some google power and experiment power was as follows</p> <h2>index.php</h2> <pre><code>&lt;?php getCountry($_SERVER['REMOTE_ADDR']); $ip=$_SERVER['REMOTE_ADDR']; function getCountry($ipAddress) { // get the country of the IP from the MAXMIND $country=""; // include functions include("geoip.inc.php"); // read GeoIP database $handle = geoip_open("GeoIP.dat", GEOIP_STANDARD); // map IP to country $country = geoip_country_name_by_addr($handle, $ipAddress); // close database handler geoip_close($handle); if ($country==""|| empty($country)) { $country="Unknown"; } return $country; } $country_code = geoip_country_code_by_addr($gi, "$ip"); // Country name is not used so commented // Get Country Name based on source IP //$country = geoip_country_name_by_addr($gi, "$ip"); geoip_close($gi); switch($country_code) { case "US": header("Location: http://site1.com "); break; case "CA": header("Location: http://site2.com "); break; case "GB": header("Location: http://site3.com "); break; default: header("Location: http://site.com "); } ?&gt; </code></pre> <p>I downloaded the <strong>geoip.inc</strong> from <a href="https://www.maxmind.com/download/geoip/api/php-20120410/geoip.inc" rel="nofollow">https://www.maxmind.com/download/geoip/api/php-20120410/geoip.inc</a></p> <p>and <strong>GeoIP.dat</strong> from <a href="http://dev.maxmind.com/geoip/legacy/geolite/" rel="nofollow">http://dev.maxmind.com/geoip/legacy/geolite/</a></p> <p><strong>BUT</strong> Something somewhere IS going wrong. The code doesn't execute, with a few errors each time. Have tried a lot many permutations of silly mistakes, but nothing worked. Calling the URL brings up the file geoip.inc's code on the URL.</p> <p>Tried to find any similar questions on SO, but couldn't. A detailed help would be appreciated. Thanks in advance.</p>