<?php // 分析 HTTP_ACCEPT_LANGUAGE 的属性 // 这里只取第一语言设置 (其他可根据需要增强功能,这里只做简单的方法演示) preg_match('/^([a-z-]+)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches); // 全部转换为小写 $lang = strtolower($matches[1]); echo $lang."<br>"; switch ($lang) { case 'zh-cn' : // header('Location: http://cn.example.com/'); echo "aa"; break; case 'zh-tw' : // header('Location: http://tw.example.com/'); echo "bb"; break; default: // header('Location: http://en.example.com/'); echo "cc"; break; }