Maxmind Geo-IP not working properly.

1 replies
Hi guys, I'm trying to create a geoip script to redirect traffic to the appropriate country based on IP, but it doesn't seem to be working.

I'm on a US IP, via Witopia VPN, and everytime I run this script it does not direct me where he US traffic is supposed to go (Google), it just goes to the "www.error.com" in the following code, and I can't figure out why.

Here's my code...

<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>


<script language="JavaScript">

var country= geoip_country_code();

if(country == "US")
{
<!--
window.location = "http://www.google.com"
//-->
}
else if(country == 'CA')
{
<!--
window.location = "http://www.yahoo.com"
//-->
}
else if(country == 'FR')
{
<!--
window.location = "http://www.ebay.com"
//-->
}
else if(country == 'DE')
{
<!--
window.location = "http://www.excite.com"
//-->
}
else
{
<!--
window.location = "http://www.error.com"
//-->
}

</script>
You can run this script here. If you have a US ip address, I would appreciate you running the script and telling me where you end up.

Does anyone have any tips to get this working properly, or have any alternate geo-redirect scripts?
#geoip #maxmind #properly #working
  • Profile picture of the author mojojuju
    First off, when I visit that page. I see NOTHING. Just a blank page.

    Looking at your source, I see that you're loading a page in a frameset. So I go to that page and I'm correctly redirected to google.com (I'm in the U.S. BTW).

    Have you determined that your IP is considered a US ip by Maxmind? Maybe you could enter your IP in the form on this page (MaxMind - IP Geolocation and Online Fraud Prevention).
    Signature

    :)

    {{ DiscussionBoard.errors[7503675].message }}

Trending Topics