By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,442 Members | 1,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,442 IT Pros & Developers. It's quick & easy.

Is it possible to redirect traffics based on country

P: n/a
Say if the visitors come from German I'd redirect them to German
website, if vistors from USA, I'd redirect them to USA websites.

Is there a way to do this with javascript?

Sep 4 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
jo**********@yahoo.com.sg said the following on 9/4/2005 1:36 PM:
Say if the visitors come from German I'd redirect them to German
website, if vistors from USA, I'd redirect them to USA websites.

Is there a way to do this with javascript?


But if the visitor is from Germany visiting Canada and signing on with a
computer that is borrowed from a French friend, what site does he get?

The answer is no.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 4 '05 #2

P: n/a
I don't need something that accurate.

Are you sure the answer is no? Is there a non javascript alternatives?

Sep 4 '05 #3

P: n/a
I mean where can I found out the IP range for Indonesian ISP?

Also, I can do something like

if lower<userIP<higher {
window.location=
else
window.location=
end if

things like that

Sep 4 '05 #4

P: n/a
jo**********@yahoo.com.sg writes:
Say if the visitors come from German I'd redirect them to German
website, if vistors from USA, I'd redirect them to USA websites.

Is there a way to do this with javascript?


Client-side Javascript, no, not with any degree of accuracy.

You might try to check the navigator.userAgent string for signs
of a language (mine says "en" somewhere), but that's hardly
perfect (no, I'm not from England or any other country with
English as language).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Sep 4 '05 #5

P: n/a
maybe you could let the user make a language selection .
and then redirect to a proper page.

Sep 5 '05 #6

P: n/a
The problem is not the language. The problem is that there is a new
business opportunities opportunity that's available only for Indonesian
citizen.

The languange is always english.

Sep 5 '05 #7

P: n/a
<jo**********@yahoo.com.sg> wrote in message news:11**********************@g49g2000cwa.googlegr oups.com...
Say if the visitors come from German I'd redirect them to German
website, if vistors from USA, I'd redirect them to USA websites.

Is there a way to do this with javascript?


It depends what you want to do with the "redirected" user:
if you want to redirect the user to a page relevant to the country
he's "visiting from" - lets say he's looging in through a US ISP,
then you want to redirect to a US subsidiary of the website,
then I would be careful redirecting without making sure there is
an escape from it to a different "country" page.
assume some soldier in Guantanamo visits your page, does he get
the Cuban or the US page? Same applies for other countries: where
do you send someone from Belize? Just curious here.
I would let the user choose the country manually, then save that
info in a "cookie" letting the user, if necessary, change the
country in case he travels (or moves).

If you want to do this, you can use the server side variables
REMOTE_HOST which isn't always filled,
and
REMOTE_ADDR which can contain a proxied address - used also for
anonymous surfing

so, as you see, the above doesn't give you a clear or sure address
where your customer comes from.
If you need to redirect them for the language, then keep in mind
that every user can set language specific entries on their
browsers, but there are also browsers used by more than one user
(internet cafe) where every user can use a different language.
In that case I would also let the user choose the desired language
from a list of supported languages.
my 2 cents (and comments)
Sep 6 '05 #8

P: n/a
JRS: In article <11**********************@g43g2000cwa.googlegroups .com>
, dated Mon, 5 Sep 2005 12:26:28, seen in news:comp.lang.javascript,
jo**********@yahoo.com.sg posted :
The problem is not the language. The problem is that there is a new
business opportunities opportunity that's available only for Indonesian
citizen.


In Indonesia, there are many people who are not Indonesian citizens.
Outside Indonesia, there are many people who are Indonesian citizens.
There may be Indonesian citizens in Indonesia who use company networks
that connect to the Internet from outside Indonesia.

You need a test on citizenship, not a test on location.

<p style="color: red; font: 160% sans-serif">
This business opportunity is available only for Indonesian citizens.</p>

Most readers will already know whether they are Indonesian citizens, and
can act accordingly; the rest will do well to find out.

If you want it to be secret and not known by Indonesians, then
(a) Don't put it in English,
(b) Don't put it on the Web.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 6 '05 #9

P: n/a
Dr John Stockton <jr*@merlyn.demon.co.uk> writes:

In Indonesia, there are many people who are not Indonesian citizens.
Outside Indonesia, there are many people who are Indonesian citizens.
There may be Indonesian citizens in Indonesia who use company networks
that connect to the Internet from outside Indonesia.

You need a test on citizenship, not a test on location.


Well, I think both tests (not at the same time! ;) ) make sense.
Look at google, for example: I, as a belgian citizen, am redirected to
www.google.be when I type www.google.com in the location bar.

... I ignore how they do that location check, though.
(IP ranges? Route? Anyone knows?)
Cheers,
Arnaud
Sep 7 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.