I have a main page 'site.com' that i would like to have automatically redirect the person to one of 3 possibilities based on browser settings; either english, chinese traditional, or chinese simpified.
So for example an english user should be redirected from 'site.com' to the site 'site..com/en/main.html'
This is a one time redirect only at the main page i do have links at the sites... but i would rather redirect the users immediately and let them change after.
Ideally something without a script (i.e., pure html) but ill take anything.
2006-09-11
14:52:18
·
8 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design
Im interested in the PHP approach... however since i have no experience in PHP i have no way to write code for it... or even know what to do with it.
All my coding is limited to mathematics and statistical programs.
Same thing for the apache... i have no clue...
2006-09-12
04:53:24 ·
update #1
In PHP, use the $_SERVER["HTTP_ACCEPT_LANGUAGE"] variable. Not only does it give you all languages in order, but it may also give you a probability value for each one. Ex: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Simply split it using a ";" and you will get an array of all accepted variables. Then, simply to a "header('location:\en');" command to go to the correct page according to the ones that you support in a simple SWITCH PHP statement.
Otherwise, if you don't want to use PHP, you'll need to use Javascript. Look at the source below for an example.
The advantage of PHP over Javascript is that you do not need to have Javascript enabled on the browser for your solution to work. It will always work because it is "server side".
2006-09-11 16:50:47
·
answer #1
·
answered by Bernz 6
·
0⤊
0⤋
in case you mean community audio equipment, then there is a superb danger the main extensively spoken language is Turkish. whether there are some modifications, Turkish is spoken and on a similar time understood in East Turkmenistan (Sinkiang, China), Kirghistan, Turkmenistan, Kazakhstan, Uzbekistan, Tajikistan, Northern Afghanistan, factors of Iran, Azerbaijan, Turkey, factors of Bulgaria, Northern Cyprus, factors of Russia. I actual have experienced a Turk having the flexibility to speak with an Uighur from Sinkiang and that i've got additionally experienced chinese language from different areas being decreased to writing to a minimum of one yet another because of the fact they'd no longer comprehend one yet another's spoken language.
2016-12-12 06:49:48
·
answer #2
·
answered by ? 4
·
0⤊
0⤋
There is an excellent JavaScript tutorial available, follow the link below (0:
2006-09-11 15:04:52
·
answer #3
·
answered by lokal2b 2
·
0⤊
0⤋
don't do it in html, very kludgy! Different links?
don't try javascript , a pain in the head!
apache has it all built in, you can re-direct it using modredirect.
Options Indexes
AllowOverride None
Order allow,deny
Allow from all
SetHandler type-map
SetEnvIf Request_URI ^/manual/de/ prefer-language=de
SetEnvIf Request_URI ^/manual/en/ prefer-language=en
SetEnvIf Request_URI ^/manual/es/ prefer-language=es
SetEnvIf Request_URI ^/manual/fr/ prefer-language=fr
SetEnvIf Request_URI ^/manual/ja/ prefer-language=ja
SetEnvIf Request_URI ^/manual/ko/ prefer-language=ko
SetEnvIf Request_URI ^/manual/ru/ prefer-language=ru
RedirectMatch 301 ^/manual(?:/(de|en|es|fr|ja|ko|ru)){2,}(/.*)?$ /manual/$1$2
2006-09-11 21:34:09
·
answer #4
·
answered by jake cigar™ is retired 7
·
0⤊
0⤋
Try here:
http://www.w3.org/International/questions/qa-apache-lang-neg
Works of the .htacess file. You add liines like this:
AddLanguage fr .fr
(fr from their example, but chinese is on the list of supported languages).
2006-09-11 15:02:53
·
answer #5
·
answered by sheeple_rancher 5
·
0⤊
0⤋
Javascript:
2006-09-11 15:05:15
·
answer #6
·
answered by agbrisco 4
·
0⤊
0⤋
Thank you! Extremely valuable information and it offers me better knowledge on the subject
2016-08-23 06:37:45
·
answer #7
·
answered by Anonymous
·
0⤊
0⤋
Thank you all for your answers and opinions.
2016-09-19 01:11:33
·
answer #8
·
answered by Anonymous
·
0⤊
0⤋