PHP的道理是一样的,示例代码亦可直接使用:
<?php
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: '>http://cn.example.com/[/url]');
break;
case 'zh-tw' :
header('Location: '>http://tw.example.com/[/url]');
break;
case 'ko' :
header('Location: '>http://ko.example.com/[/url]');
break;
default:
header('Location: '>http://en.example.com/[/url]');
break;
}
?>
只用修改相关的执行就可以 答案补充
<?php
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: '>http://cn.example.com/[/url]');
break;
case 'zh-tw' :
header('Location: '>http://tw.example.com/[/url]');
break;
case 'ko' :
header('Location: '>http://ko.example.com/[/url]');
break;
default:
header('Location: '>http://en.example.com/[/url]');
break;
}
?>
只用修改相关的执行就可以 答案补充
你看不到代码?上面的代码就可以直接合作啊,或是单独做到文件里面引用也可以的。