View Full Version : Country redirect 'simple version'
High Roller
04-27-2002, 07:59 PM
I know country redirect scripts are not 100% accurate
and I know there are complex expensive ones, I need one where I can add code to a page and it will read the browser language or anything else, and redirect to a site of my choice.
That way I don't have to pay webmasters for asian traffic.
WiredGuy
04-27-2002, 08:11 PM
If you want to do it based on browser language, you can do a perl script to redirect pages based on the browser properties (ie: extract the browser name, look for specific browsers and redirect those away).
WG
High Roller
04-27-2002, 08:22 PM
could you give me more info please
I am not a programmer so I do not understand how to do that.
I just want a paragraph of code to add.
moose
04-27-2002, 08:29 PM
there is a simple way like you want. i dont see an email address listed,but you can mail me at moose @ xswealth.com and ill dig it up for you.
foxxx
04-27-2002, 08:34 PM
have a look around http://cgi.resourceindex.com
should be something like what your after there...
AgentCash
04-27-2002, 09:25 PM
<script>
var url = "http://www.agentcash.com/index-";
var ext = ".htm";
if(navigator.appName == "Netscape"){ var lang = navigator.language }
if(navigator.appName == "Microsoft Internet Explorer"){ var lang = navigator.browserLanguage }
lang = lang.toLowerCase();
redir = url + lang + ext;
self.location=redir;
</script>
Note that in this code the lang variable is written as "language-country" so in my case it says "en-us" (english-united states)
WiredGuy
04-27-2002, 10:09 PM
Agentcash said it well. You now have stored in lang variable the language code of the browser. If your french canadian it should be FR_CA or CA_FR, I forget. Either way, there's an RFC you can call up which lists all international country codes which browsers adapt to and you can redirect based on that.
WG
AgentCash
04-27-2002, 10:18 PM
Language Codes
http://www-old.ics.uci.edu/pub/ietf/http/related/iso639.txt
Country Codes
http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
You could also just do something like
<script>
var china = "http://www.agentcash.com/links";
var japan = "http://www.agentcash.com/links";
if(navigator.appName == "Netscape"){ var lang = navigator.language }
if(navigator.appName == "Microsoft Internet Explorer"){ var lang = navigator.browserLanguage }
lang = lang.toLowerCase();
if(lang == "zh-cn") { self.location=china; } // Chinese-China
if(lang == "ja-jp") { self.location=japan; } // Japanese-Japan
</script>
if you don't have many countries you want to redirect.
keyman
04-27-2002, 11:25 PM
If you don't want to use client side script, then the browser usually sends an Accept-Language: header with the http get. The cgi environment var is HTTP_ACCEPT_LANGUAGE.
exitmoney
04-28-2002, 01:33 AM
check out http://www.trixscripts.com/scripts21-30.html
script #21
that is about the best you could find out there, and the price is very cheap also!
I'd say that substantial number of unwanted visitors uses proxy, but this is my feeling only, that those surfers tend to switch proxies but they don't switch accept language in their browser. So probability that japanese surfer WILL have japanese language set is close to 100% unlike his IP.
This is the easiest version of PHP script I am using to redirect non english surfers. "En" surfers will get us.html, anybody else foreign.html.
<? if (eregi( "en", $HTTP_ACCEPT_LANGUAGE)) { readfile("us.html");
} else
{ readfile("foreign.html");
}
?>
Or it can be set up vice versa, instead of "en" you can put unwanted language like "ja" , instead of us.html put japan.html and instead of foreign.html put anybodyelse.html - then all japanese surfers will go to japan.html even if they have added "en" to accept language, the rest of world will go to anybodyelse.html
Of course this can be more complex, but don't want to post it here due to possible misuse
XM
SexySites
04-28-2002, 10:18 AM
Originally posted by exitmoney
check out http://www.trixscripts.com/scripts21-30.html
script #21
that is about the best you could find out there, and the price is very cheap also!
cheap! haha...dont think so
laters,
Chris
High Roller
04-28-2002, 01:15 PM
thanks for your help guys
I am not a programmer so some of that I did not quite understand, adding it to a webpage though is no problem.
To be more specific
I will probably except traffic from 30 good countries
like germany, us, uk, and so on, and just redirect away the other countries, is there a better script for that type of thing?
vBulletin® v3.7.3, Copyright ©2000-2012, Jelsoft Enterprises Ltd.