You could do it by using a geo IP api tool..eg http://api.hostip.info/country.php?ip=0.0.0.0 <?php $content = file_get_contents('http://api.hostip.info/country.php?ip='.$_SERVER['REMOTE_ADDR']); if($content != 'UK'){ header('location: notallowedcountry.html'); exit; } ?> PHP: (not tested)
Because it can be slow to get query another host ("hostip.info" for example) you can download and use the GEOIP PHP Api ( from maxmind.com) directly from your website... It look like this: <?php // This code demonstrates how to lookup the country by IP Address include("geoip.inc"); $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); $country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); if($country == "UK") /* If UK people don't deserve your website, do they deserve anything? ;-) */ { header('Location: notallowedcountry.html'); } ?>
it is impossible, if you want to do it, you have to update IP list-> pay for it, of course. All IP address of client will be reseted so how can u find where IP come from.