I would like to approve only traffic from US and other traffic redirect to other site, how can I do it?
You'll need an IP to Country database, I'm not sure if there is a free one or not. . . But you get that, and query the ip, then mod the header if they aren't from the US. If you google 'IP to Country database' you will be able to find one. =]
You can do it by "Geo IP"... Max Mind, have a free database for that, with API support for all popular languages. If you need help we are here to help you, just post you code what you have done so far, and we will try to help you.
My server dotn allow to install maxmind software, i would have to upgrade to dedicate server.. Any alternatives?
Ok being I'm new here I thought I might try and be helpful so I've just coded you something that should do it without any MySQL database. It uses files provided by ip2country. You can download it from: danstuts.com/code/ip2location.zip Demo: danstuts.com/samples/ip2loc/location.php The demo will send you to Google if your from America, and if not it will send you to my homepage. Just upload the files then change the URLs in the location.php file. <?php $the_users_ip = $_SERVER['REMOTE_ADDR']; $two_letter_country_code=iptocountry($the_users_ip); if ($two_letter_country_code=="US") { // The user is from the states, thus send them to one page header('Location:GOOGLE I CANT TYPE URLS YET');[ // Else the user is from outside US } else { header('Location:MY WEBSITE'); } function iptocountry($ip) { $numbers = preg_split( "/\./", $ip); include("ip_files/".$numbers[0].".php"); $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]); foreach($ranges as $key => $value){ if($key<=$code){ if($ranges[$key][0]>=$code){$country=$ranges[$key][1];break;} } } if ($country==""){$country="unkown";} return $country; } ?> PHP:
do you think it would be possible to do this on the registrar level, or a little off topic, is it possible to build in an option to load balance from the registrar or if you are the registrar to add DNS load balancing as an option.
There is no need for installing it, like you are installing some binary application, you only need to copy it thru FTP, and use API for reading Geo IP database. Here are direct links to files Geo IP Country - binary Geo IP City - binary. Then go to Max Mind website, and get API for you language. There is also a CSV version, that I have used by converting it into DB (MySQL)... They have very accurate database, but if you want more accurate there is a paid version.
I have personally used country2ip and it works great, my advice would be to parse the ip2c files into a mysql database and have a script run weekly to update your ip2c database, then its easy to run mysql queries to find out which country your visitor is from and redirect accordingly.
Sorry if this is a really noobish question, i can't seem to get my head around this GeoIp etc. Am I required to rewrite my webpages in php to use this?