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

how to ban any IP country ?????

Discussion in 'Black Hat SEO' started by zlogz, Mar 5, 2011.

  1. zlogz

    zlogz Regular Member

    Joined:
    Jan 22, 2011
    Messages:
    385
    Likes Received:
    40
    Location:
    -
    Hi ,

    i have a website , but i only want US ip can see my website . Do anyone know how to accept or block all other country ??? htacess ?
     
  2. squark

    squark Junior Member

    Joined:
    May 22, 2008
    Messages:
    156
    Likes Received:
    1,206
    Get the free country database from maxmind.com. It has examples in PHP, Python, Perl, etc. on their site. If the user isn't from the U.S. just redirect them to wherever you want to send them.
     
    • Thanks Thanks x 1
  3. yooplex

    yooplex Registered Member

    Joined:
    Jan 15, 2010
    Messages:
    80
    Likes Received:
    10
    add this code to your head

    HTML:
    <script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
    
    <script language="JavaScript"> 
    if (geoip_country_code()!="US")
    	{
    	document.write("<meta http-equiv='refresh' content='0; URL=http://www.google.com'>");
    	}
    </script> 
    this example is to redirect all visitor you don't like to google.com

    change google.com with page you like to redirect visitor not from US

    please don't forget to click THANKS
     
    • Thanks Thanks x 4
  4. zlogz

    zlogz Regular Member

    Joined:
    Jan 22, 2011
    Messages:
    385
    Likes Received:
    40
    Location:
    -
    thank for the script..very nice , but if i want to allow some IP from banned country...how i can do ?
     
  5. squark

    squark Junior Member

    Joined:
    May 22, 2008
    Messages:
    156
    Likes Received:
    1,206
    You can't get IP from the client without making a server callback. In a similar situation I wrote a quick Google App Engine script to return the client's IP in a jsonp callback. But most of the time the client doesn't even know it's true internet address... it will have a local address instead of the public IP.

    Also, if you're using the javascript listed above you're not actually blocking any of your content. The content is still delivered to the... they're just quickly redirected away from it.

    So the javascript method is *not* an acceptable solution if you're trying to secure or protect your content. It can be an acceptable solution if you're just wanting to redirect them to something more appropriate for their region, but it's not a security constraint.