Need a simple geo redirect script

SEO Sniper

Registered Member
Joined
May 17, 2015
Messages
82
Reaction score
51
Hey guys,

I need a way to filter tier 1 traffic in my landing page. Any geo redirect script you guys can point out? Thanks
 
"geo redirect script php" returns a ton of results. Did that not work for you? Anything specific you are looking for?
 
here you go:

Code:
<?php
/* quick and dirty GEO cloaking script
   by styx @ argo-content.com 2014 */


   $geo[0][0]='DE';
   $geo[0][1]='http://google.com';
   $geo[1][0]='US';
   $geo[1][1]='http://aol.com';


   $cnt=sizeof($geo);
   $ip=$_SERVER['REMOTE_ADDR'];
   if(isset($ip)and&ip2long($ip) !== false) {
      $fp=fsockopen("asn.shadowserver.org",43,$ern,$ers,20);
      if(!$fp) { die("$ern:$ers\n"); }
      $data="begin origin\n$ip\nend\n";
      fwrite($fp,$data);
      while(!feof($fp)) {
         $output.=fgets($fp,255);
      }
      fclose($fp);
      $out=explode('|',$output);
      $match=trim($out[4]);
      for($i=0;$i<$cnt;$i++) {
         if($match===$geo[$i][0]) {
            $u=$geo[$i][1];
            header("Location: $u");
         }
      }
   }
?>
 
Either use a script like above that connects to a third-party lookup server, or grab the free geoip database from MaxMind and roll your own.
 
You could also try a Geo or latency based DNS solution. You'll need multiple servers for it though.
 
latency is just guess work, its too unreliable..
 
Back
Top