原文:http://www.clearstudy.cn/archives/77
- <?
- error_reporting(E_ALL ^ E_NOTICE);
- 分析 HTTP_ACCEPT_LANGUAGE 的属性
- 这里只取第一语言设置 (其他可根据需要增强功能,这里只做简单的方法演示)
- preg_match('^([a-z-]+)i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches);
- $lang = $matches[1];
- switch ($lang) {
- case 'zh-cn'
- header('Location [url]httpcn.example.com[url]');
- break;
- case 'zh-tw'
- header('Location [url]httptw.example.com[url]');
- break;
- case 'ko'
- header('Location [url]httpko.example.com[url]');
- break;
- default
- header('Location [url]httpen.example.com[url]');
- break;
- }
- ?>