1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Blocking a specific country from visiting my website

Discussion in 'Black Hat SEO' started by AnonLeo, Jan 30, 2014.

Tags:
  1. AnonLeo

    AnonLeo Regular Member

    Joined:
    Nov 23, 2013
    Messages:
    362
    Likes Received:
    263
    Location:
    USA
    Ok, so there is a country that I don't like, I want to block everyone from there and leave a 'Nice' message for them when they visit my website.
    I want that message to appear on ALL of the pages of my website.
    How can I do that?

    Thanks
     
  2. Schvamp

    Schvamp Power Member

    Joined:
    Feb 13, 2012
    Messages:
    684
    Likes Received:
    549
    Location:
    Hogwarts
    Search for GEO Redirect script. It's a simple fix, a bit trickier if you don't know any coding tho.
    You use any CMD?
     
    • Thanks Thanks x 1
  3. AnonLeo

    AnonLeo Regular Member

    Joined:
    Nov 23, 2013
    Messages:
    362
    Likes Received:
    263
    Location:
    USA
    Thanks & which CMD are you talking about?
    The cmd.exe? What does that has to do with websites
     
  4. youtalkmedia

    youtalkmedia Senior Member

    Joined:
    Dec 5, 2011
    Messages:
    830
    Likes Received:
    375
    Occupation:
    Web Developer
    Location:
    Toronto
    Home Page:
    You can do this by blocking ip ranges from your site.

    Becareful with this, as it can also block other countries along with the one you want to block.

    Take a look at .htaccess IP blocking, and find out the IP ranges used in the country you want to block
     
    • Thanks Thanks x 1
  5. Bokva

    Bokva Regular Member

    Joined:
    Jan 26, 2010
    Messages:
    201
    Likes Received:
    110
    Occupation:
    Graphic and Web design
    Location:
    Underground
    Use some third part api, as ip ranges change too much.

    You can try api.wipmania.com:

    Code:
    <?php
    $country_code = file_get_contents('http://api.wipmania.com/' . $_SERVER['REMOTE_ADDR'] . '?' . $_SERVER['SERVER_NAME']);
    echo $country_code;
    if($country_code=="US"){
        echo "Greetings and stuff..."
    }
    ?>
    I used that on one of my sites before, I just tried it and it's still working.
     
    • Thanks Thanks x 2
  6. Schvamp

    Schvamp Power Member

    Joined:
    Feb 13, 2012
    Messages:
    684
    Likes Received:
    549
    Location:
    Hogwarts
    Sorry, typo. It should be CMS (Content Management System) for example wordpress or such.

    A while back I used a php script shared here at bhw, can't find it now tho.
    But Bokva seems to have a solution for you.
     
    • Thanks Thanks x 1
  7. JoeMongan

    JoeMongan Jr. VIP Jr. VIP Premium Member

    Joined:
    Sep 24, 2013
    Messages:
    1,712
    Likes Received:
    3,553
    Location:
    International Waters
    Last time I checked you can install a plugin to do this the easy way if you are using WP meaning you can block
    specific GEO locations. My opinion is to not do this since the traffic will not hurt anything. Even junk traffic helps your Alexa ranking.

    -RK
     
    • Thanks Thanks x 1
  8. chipmunk951

    chipmunk951 Senior Member

    Joined:
    May 10, 2010
    Messages:
    1,011
    Likes Received:
    443
    Occupation:
    IM
    Location:
    Zimbabwe
    Maxmind Database API can do this for ya
     
    • Thanks Thanks x 1