redirecting based on geographical IP

Discussion in 'BlackHat Lounge' started by expatdude, Apr 13, 2009.

  1. expatdude

    expatdude Newbie

    Joined:
    Jun 15, 2008
    Messages:
    5
    Likes Received:
    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?
     
  2. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,235
    Occupation:
    Retired
    Location:
    Old Peoples Home
  3. expatdude

    expatdude Newbie

    Joined:
    Jun 15, 2008
    Messages:
    5
    Likes Received:
    0
    Thanks for the heads-up. I'm looking or something which can detect and then redirect, all in one go...
     
  4. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,235
    Occupation:
    Retired
    Location:
    Old Peoples Home
    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.
     
    • Thanks Thanks x 1
  5. Fudnut

    Fudnut Registered Member

    Joined:
    Dec 22, 2007
    Messages:
    85
    Likes Received:
    27
    Location:
    Australia
    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
     
    • Thanks Thanks x 2
  6. The Scarlet Pimp

    The Scarlet Pimp Senior Member

    Joined:
    Apr 2, 2008
    Messages:
    980
    Likes Received:
    3,490
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    an .htaccess file can redirect by ip number.
     
    • Thanks Thanks x 1
  7. expatdude

    expatdude Newbie

    Joined:
    Jun 15, 2008
    Messages:
    5
    Likes Received:
    0
    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.)
     
  8. Fudnut

    Fudnut Registered Member

    Joined:
    Dec 22, 2007
    Messages:
    85
    Likes Received:
    27
    Location:
    Australia
    Yep, that's the shot.
    Full list of codes here hxxp://wwwDOTmaxmindDOTcom/app/iso3166