Everyone is using google. You can use a Chinese system to open google's homepage, which is naturally a Chinese homepage, rather than other languages. Because google will automatically determine the preferred language used by the user system.
How can we make it as simple as google,
The HTTP Headers Information sent from the browser to the web server contains the Accept-Language Information.
This information is the tool in the browser-> Internet Options-> general language, which is used to set acceptable language preferences of the browser, it can be a priority column in multiple acceptable languages.
The following uses PHP as an example,
The user's acceptable language information is stored in $ _ SERVER ['HTTP _ ACCEPT_LANGUAGE,
The variable information is similar to "zh-cn". For multi-language columns, it is similar to "zh-cn, en; q = 0.8, ko; q = 0.5, zh-tw; q = 0.3"
The following problems can be solved.
Program code
<? Php
Error_reporting (E_ALL ^ E_NOTICE );
// Analyze the HTTP_ACCEPT_LANGUAGE attributes
// Here, only the first language settings are used (other functions can be enhanced as needed. Here, we will only make a simple demonstration)
Preg_match ('/^ ([a-z-] +)/I', $ _ SERVER ['HTTP _ ACCEPT_LANGUAGE '], $ matches );
$ Lang = $ matches [1];
Switch ($ lang ){
Case 'zh-cn ':
Header ('location: http://cn.example.com /');
Break;
Case 'zh-tw ':
Header ('location: http://tw.example.com /');
Break;
Case 'ko ':
Header ('location: http://ko.example.com /');
Break;
Default:
Header ('location: http://en.example.com /');
Break;
}
?>