Main Topics
Browse All TopicsHow can i redirect a visitor to a certain page based on the country of the user?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You could redirect based on language of browser...
<html>
<head>
<script type="text/javascript">
// IE default language for the browser
if (navigator.browserLanguage
// IE browser language set by the user
if (navigator.userLanguage){l
// IE operating system language
if (navigator.systemLanguage)
// Netscape language sniff
if (navigator.language){langu
// Turn all variants of "en-us", "en-au" etc into plain "en"
if (language.indexOf('-')==2)
if (language=='da') {direct='http://www.yahoo.
else if (language=='sw') {direct='http://www.yahoo.
else if (language=='en') {direct='http://www.yahoo.
else {direct='http://www.echoec
window.location.href=direc
</script>
</head>
<body>
</body>
</html>
well you could check their system time, compare it to a time that comes from the server and is written in to javascript, for example, if you were using asp...
<%@ LANGUAGE=VBSCRIPT%>
<html>
<head>
<script language="JavaScript" type="text/javascript">
var serverDateTime = new Date(<%=Date()%>);
var clientDateTime = Date().getDate();
compareDate_redirect(clien
function compareDate_redirect(dClie
//- code here for compare and redirect if needed...
}
</script>
</head>
<html>
....
</html>
</head>
The language check is another good approach, if you wanted to really narrow it down I would use both my idea and mmon's, a person using a specific language on their system is a semi-reliable, however people can live in other areas and speak other languages, if you check the timezone AND the language you could really narrow it down.
you can also redirect using meta tags like this
syntax:
<meta http-equiv="refresh" content=(delay in seconds);url="place to goto">
example:
<meta http-equiv="refresh" content="25;url=http://www
Here is a client side script. It would be far better to use a serverside script incase the user's browser doesn't support javascript.
<SCRIPT LANGUAGE="JavaScript">
<!--
var Lang;
Lang = navigator.userLanguage
switch(Lang)
{
case "zh" : PlaceToGo = "http://www.me.com/chinese
break;
case "en" : PlaceToGo = "http://www.me.com/English
break;
case "da" : PlaceToGo = "http://www.me.com/Danish.
break;
default: PlaceToGo = "http://www.me.com/English
}
document.location.href = PlaceToGo;
document.location.reload;
-->
</script>
<!--
Here is a list of about half of the countries and languages
you can look at all of them if you have ie by going internet options language add.
Catalan = ca
Chinese[China] = zh-cn
Chinese[Hong Kong SAR] = zh-hk
Chinese[Macau SAR] = zh-mo
Chinese[Singapore] = zh-sg
Chinese[Taiwan] = zh-tw
Chinese = zh
Croatian = hr
Czech = cs
Dainish = da
Divenhi = div
Dutch[Belgium] = nl-be
Dutch[Netherlands] = nl
English[Australia] = en-au
English[Belize] = en-bz
English[Canada] = en-ca
English[Caribbean] = en
English[Ireland] = en-ie
English[Jamaica] = en-jm
English[New Zealand] = en-nz
English[Philippines] = en-ph
English[South Africa] = en-za
English[Trinidad] = en-tt
English[United Kingdom] = en-gb
English[Zimbabwe] = en-zw
English[en] = en
-->
if you used php it could be done like this:
<?php
$Lang = GetLang();
$Address = SwitchLang($Lang);
echo "<meta http-equiv=\"refresh\" content=\"25;url=\"";
echo $Address;
echo "\">";
/**** You will have to create a function to get the server variable for language, and make a function to switch the language/country with a physical http address. ****/
?>
Another idea, if you're targeting certain countries or regions...
Show a bunch of country flags, and let the user pick their language... I've seen that done a few times and it's usually effective (as long as you don't have some ugly looking flags!). In that case you might want to create your own quality versions!
Heh... you should always try every option yourself, instead of asking questions like:
"On what browsers does this code works?"
Obviously if you're using a windows system, you can't use earlier versions of a browser, or test on a mac; but you can still test any other windows browser, i.e. Mozilla, Gecko, Opera, etc. etc.
I can't imagine taking someone else's word (no matter who they are!) for what works (especially since you know what functionality you're looking for!). Anything else is just lazy. You CAN download those, at least.
The PHP code will work regardless of the browser type because it is executed on the server end. However I am pretty sure the javascript should work with just about any modern day browser I have not yet tested it with Netscape and mozilla. But I Know that it does work with Internet Explorer. It should work with netscape and mozilla becase I think they do support the code I have written. Even so the first page that uses the redirection should have plain text links to get to the pages. Using plain text links will also keep you from being penalized by some search engines for redirecting them.
The code should work with the newer versions of netscape.
Just a qick statistical rating from data I have personaly gather over a the last 6 month period Here is how browser popularity goes.
Internet Explorer 86.5%
Netscape/Mozilla 7.8%
Opera 1.02%
Konqueror .5%
Lynx .3%
Search Spiders 3.9%
These statistics were recorded as unique hits on 12 different web sites.
This is based on a poll of 1,000,982 Unique Hits.
This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
<note>
Unless it is clear to me that the question has been answered I will recommend delete. It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
</note>
If the user does not know how to close the question, the options are here:
http://www.experts-exchang
Cd&
Business Accounts
Answer for Membership
by: thanassisPosted on 2003-04-03 at 22:26:12ID: 8267424
In which language?