Freedoom |
06-19-2015 03:47 PM |
Geo redirect code
Hi,
I have this code to redirect traffic :
Code:
<?PHP
include('/home/domain/public_html/geoip/geoip.inc'); //this file must exist in your directory
$gi = geoip_open('/home/domain/public_html/geoip/GeoIP.dat',GEOIP_STANDARD);
// get the ip of the visitor
$addr = getenv('REMOTE_ADDR');
// translate his ip to a country code
$country = geoip_country_code_by_addr($gi, $addr);
// close the geo database
geoip_close($gi);
$badcountry = array('TR','IN','ID',"PK","CN",'MY');
// You can change the example with any countries that you want to block
// redirect them if they suck
if(in_array($country, $badcountry))
header('Location: http://www.domain.com/'); //enter a url or page on your site
?>
How can I redirect the "good" traffic(all the countries that aren't in the bad country array) to other url?
Thanks
|