NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page How to redirect my visitors depending on where they come from (UK or USA)

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-31-2006, 07:10 PM THREAD STARTER               #1 (permalink)
Ash
NamePros Regular
Join Date: Mar 2006
Location: UK
Posts: 204
Ash is an unknown quantity at this point
 



How to redirect my visitors depending on where they come from (UK or USA)


Hi,
How do i make it so that when someone goes to: www.nintendoshop.net

If they are from the UK, they get redirected to uk.nintendoshop.net and if they are from anywhere else in the world (such as the usa) they get redirected to nintendoshop.net

Does anyone know how to do this? (The best/easiest way)

Thanks.
Ash is offline  
Old 12-31-2006, 07:14 PM   #2 (permalink)
Account Closed
 
Alex.'s Avatar
Join Date: Nov 2006
Location: Uk
Posts: 601
Alex. is on a distinguished road
 


Ethan Allen Fund Third World Education
as far as i know, the only way to do it would be by tracing their ip, like sourceforge does when you download

this might not be reliable, as ips can be spoofed.

the other way is by asking the user then placing a cookie with their info on their pc.
Alex. is offline  
Old 12-31-2006, 07:42 PM THREAD STARTER               #3 (permalink)
Ash
NamePros Regular
Join Date: Mar 2006
Location: UK
Posts: 204
Ash is an unknown quantity at this point
 



Ah good idea, that might be even better... but do you know how to do it?

If anyone knows a GOOD way to do it and they can do it for me (cheap) i don't mind paying them...
Ash is offline  
Old 12-31-2006, 07:56 PM   #4 (permalink)
Account Closed
 
Alex.'s Avatar
Join Date: Nov 2006
Location: Uk
Posts: 601
Alex. is on a distinguished road
 


Ethan Allen Fund Third World Education
which method?
select your shop? ill have a go at it for you.
Alex. is offline  
Old 12-31-2006, 08:11 PM   #5 (permalink)
Hi :)
 
Mark's Avatar
Join Date: Mar 2004
Location: NC
Posts: 9,567
Mark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatness
 

Member of the Month
August 2004
Ethan Allen Fund
There's many ways really - .... but none are foolproof.

PHP Code:

<?php
    $locales 
$_SERVER['HTTP_ACCEPT_LANGUAGE'];
    if ( 
$locales == "" ) {
$gouri 'http://nintendoshop.net/';
    } else {
    
$semicolon = array(";");
    
$lesssemicolon str_replace($semicolon",""$locales");
    
$breakdown explode(",",$lesssemicolon);
    
$lang_count strtolower("$breakdown[0]");
    }
    if ( 
$lang_count == "en-uk" ) {
$gouri 'http://uk.nintendoshop.net/';
????: NamePros.com http://www.namepros.com/programming/275374-how-redirect-my-visitors-depending-where.html
}    else    {
$gouri 'http://nintendoshop.net/';
    }
header("Location: $gouri");
?>
This of course only works for language specific visitors of the UK

en-uk visitor (Only those with their "main locale" set on their browser to English/United Kingdom) would go to "uk.nintendoshop.net" - All others will go to "nintendoshop.net" .... (Whether they have a locale set or not).


Just a different way to approach it

Remember though !
Quote:
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
__________________
When the man at the door yelled "Alcohol , Tobacco , and Firearms" .... I just assumed it was a delivery !
Mark is offline  
Old 12-31-2006, 08:43 PM   #6 (permalink)
Senior Member
 
RegisterRants's Avatar
Join Date: Oct 2006
Location: NJ
Posts: 1,152
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
 




If you don't need it to happen automatically, you can do what UPS and other places do. Go to ups.com to see what I mean. I can do that for you, just PM me.
__________________
Web Development
RegisterRants is offline  
Old 12-31-2006, 08:49 PM   #7 (permalink)
NamePros Regular
Join Date: Feb 2006
Posts: 584
jerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to all
 



You can use the Geo-IP Database (for a price).

Their database is very comprehensive with many ISPs listed.

LINK : http://www.maxmind.com/app/country
jerometan is offline  
Old 12-31-2006, 10:29 PM THREAD STARTER               #8 (permalink)
Ash
NamePros Regular
Join Date: Mar 2006
Location: UK
Posts: 204
Ash is an unknown quantity at this point
 



Thanks for the help - im still not 100% sure what kind of redirect i want... so just a quick question:

If i use a simple redirection code (like the php code in a few posts above me) where will a search engine bot go? Will the search engine bot also be redirected or...?
Ash is offline  
Old 12-31-2006, 10:32 PM   #9 (permalink)
Senior Member
 
RegisterRants's Avatar
Join Date: Oct 2006
Location: NJ
Posts: 1,152
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
 




Sometimes the search engine will follow. Sometimes it will say "screw this".
__________________
Web Development
RegisterRants is offline  
Old 12-31-2006, 11:05 PM   #10 (permalink)
Hi :)
 
Mark's Avatar
Join Date: Mar 2004
Location: NC
Posts: 9,567
Mark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatness
 

Member of the Month
August 2004
Ethan Allen Fund
If you build it - They will come !
__________________
When the man at the door yelled "Alcohol , Tobacco , and Firearms" .... I just assumed it was a delivery !
Mark is offline  
Old 01-01-2007, 03:03 AM   #11 (permalink)
NamePros Regular
Join Date: Feb 2006
Posts: 584
jerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to all
 



Originally Posted by Ash
Thanks for the help - im still not 100% sure what kind of redirect i want... so just a quick question:
????: NamePros.com http://www.namepros.com/showthread.php?t=275374

If i use a simple redirection code (like the php code in a few posts above me) where will a search engine bot go? Will the search engine bot also be redirected or...?
It depends on the way the bot is programmed.
If you use the above PHP method, it will follow as a header that the site is moved will be sent.
jerometan is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 11:42 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger