Javascripts geo redirect

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

Joe

VIP Member
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
Close
very nice SV, I never knew about 'http://api.hostip.info/country.php?ip='.
 
0
Close
it can be php :)
cheers SV
Joe
 
0
Close
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
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back