ISP redirection script like Google has

  • musik
  • Legend
  • Super Moderator
  • User avatar
  • Posts: 6893
  • Loc: up a tree

Post 3+ Months Ago

Hi folks,

Can anyone give me more information on the kind of script that Google has, in the respect that for example, if I went to http://www.google.com from an australian ISP it redirects me to http://www.google.com.au automatically.

Any info would be much appreciated!

Rose
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

just making a shot in the dark here, but I would guess that if it's done by a script at all, it's probably done by the REMOTE_HOST's domain, ie (perl):
Code: [ Select ]
$ref = $ENV{REMOTE_HOST};
@refarr = split(/\./,$ref);
$dom= pop @refarr;
  1. $ref = $ENV{REMOTE_HOST};
  2. @refarr = split(/\./,$ref);
  3. $dom= pop @refarr;

I think it's more likely they have their server set up to redirect via REMOTE_HOST to the proper pages
  • Jerrek
  • Graduate
  • Graduate
  • User avatar
  • Posts: 158
  • Loc: Melbourne, AUS

Post 3+ Months Ago

Hi there,
I think what Rose is trying to ask is, how do they know that the REMOTE_HOST is an Aussie ISP? Doing the actual redirect is fairly easy...

Correct me if I'm wrong ;)

Steve.
  • musik
  • Legend
  • Super Moderator
  • User avatar
  • Posts: 6893
  • Loc: up a tree

Post 3+ Months Ago

lol well you know what i mean, i think thats what i mean.,.. umm :roll: :lol:

yeah well like google has. i know how to redirect someone, but how to specify what country they are from?
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

there are a variety of ways to find that out. Specifically, if you were going to do this in Perl, you would probably use IP-Country, like so:
Code: [ Select ]
use IP::Country::Fast;
my $reg = IP::Country::Fast->new();
$cc = $reg->inet_ntocc($ENV{REMOTE_ADDR});

print "Content-type: text/html\n\n";
print "$cc";
  1. use IP::Country::Fast;
  2. my $reg = IP::Country::Fast->new();
  3. $cc = $reg->inet_ntocc($ENV{REMOTE_ADDR});
  4. print "Content-type: text/html\n\n";
  5. print "$cc";

All this does is print out the users country code, but you could just as easily redirect based on that code as well (using an if/else to get the right page to send)
  • Jerrek
  • Graduate
  • Graduate
  • User avatar
  • Posts: 158
  • Loc: Melbourne, AUS

Post 3+ Months Ago

Hi this213,
I don't suppose you know of a PHP way of doing this do you?

Country code would be a fine way of determining it :)

Thanks!
Steve
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

I sure don't - but then I've only been coding PHP for a short while. The perl IP-Country module uses an internal database though. If you wanted to do the same thing in PHP, I think you'd have to create a map of some sort somewhere that mapped the IP addresses to their owners country (that's what the perl module does anyway)

It looks like something I might be looking into though - perhaps exporting the perl db for PHP.

If you're interested, here's the raw data from the mod:
http://www.ribosi.com/trash/cc/cc.txt
  • musik
  • Legend
  • Super Moderator
  • User avatar
  • Posts: 6893
  • Loc: up a tree

Post 3+ Months Ago

this213, i really appreciate all your help! :)
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

np, I'm helping me too :)

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 84 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.