Dynadot โ€” .com Transfer

Javascripts geo redirect

NamecheapNamecheap
Watch
Impact
48
Does anyone know where i can get a simple javascript re-direct?
say someone goes to mysite.com
but they are from the UK so it redirects them to .co.uk
i searched good, but the one on there was confusing
and when it did work, it was constantly refreshing the page
Joe
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
Does it have to be JavaScript? Could always use PHP :)

PHP:
<?php

$ip = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
$country = trim(file_get_contents('http://api.hostip.info/country.php?ip='.$ip));

switch($country)
{
  case 'UK':
        header('Location: http://www.domain.co.uk');
        break;
}
//Etc

?>
 
0
•••
very nice SV, I never knew about 'http://api.hostip.info/country.php?ip='.
 
0
•••
it can be php :)
cheers SV
Joe
 
0
•••
TheArbiter said:
Does anyone know where i can get a simple javascript re-direct?
say someone goes to mysite.com
but they are from the UK so it redirects them to .co.uk
i searched good, but the one on there was confusing
and when it did work, it was constantly refreshing the page
Joe
Make sure you're taking proxies into mind here, the code should handle it, though.

Oherwise great use of this code.

-Steve
 
0
•••
Appraise.net
Spaceship
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back