redirecting based on geographical IP

expatdude

Newbie
Joined
Jun 15, 2008
Messages
5
Reaction score
0
I'm looking for a product which will redirect surfers from certain countries because there are some countries which I simply don't want business from at all. So far found georedirect.com. Anybody know anything about it or have a program which they'd vouch for?
 
Thanks for the heads-up. I'm looking or something which can detect and then redirect, all in one go...
 
That all you need to do it all in one - look at using ClientLocation.address.country_code to get the country of the IP and then do a meta refresh to reditect to the page for the country.
 
install Maxmind Geo Lite www(DOT)maxmind(DOT)com/app/geolitecity on your server then use something like this in your redirect script.
Code:
<?php
$country_code = apache_note("GEOIP_COUNTRY_CODE");
if ( $country_code == "US"){
header ("Location: hxxp://offer(DOT)com");
}
 else if ( $country_code == "GB") {
header ("Location: hxxp://thisdomain(DOT)com");
}
else
header ("Location: hxxp://otherdomain(DOT)com");

?>

Had to write the urls like that as can't post links with less then 15 posts
 
Hey Fudnut,

Thanks, I think that goes a long way. I get the concept, I think. Let's say I want to block three countries Barfiia (BA), Merdistan (MD) and the Socialist Republic of Yuck (RY), but no-one else. I only have two sites, one the real site and the other a holder page halfway across the globe. These three countries go to the holder page, everyone else can go to the real site.

Would this be-

Code:
<?php
$country_code = apache_note("GEOIP_COUNTRY_CODE");
if ( $country_code == "BA"){
header ("Location: hxxp://nutstoyou(DOT)com");
}
 else if ( $country_code == "RY") {
header ("Location: hxxp://tnutstoyou(DOT)com");
} 
 else if ( $country_code == "MD") {
header ("Location: hxxp://nutstoyou(DOT)com");
}
else
header ("Location: hxxp://realwebsite(DOT)com");

?>

correct?

The htaccess is great, but for indicidual IPs. (I already do that for a few overactive ones, but I'd like to ban entire countries.)
 
Hey Fudnut,

Thanks, I think that goes a long way. I get the concept, I think. Let's say I want to block three countries Barfiia (BA), Merdistan (MD) and the Socialist Republic of Yuck (RY), but no-one else. I only have two sites, one the real site and the other a holder page halfway across the globe. These three countries go to the holder page, everyone else can go to the real site.

Yep, that's the shot.
Full list of codes here hxxp://wwwDOTmaxmindDOTcom/app/iso3166
 
Back
Top