[代码] [PHP]代码
01 | $language = substr ( $_SERVER [ 'HTTP_ACCEPT_LANGUAGE' ],0,2); |
02 | //获取访客语言,是HTTP头信息的ACCEPT_LANGUAGE的前两个字符 |
03 | // http://blog.ddian.cn |
04 | if ( $language != 'zh' ){ |
05 | //zh是中文,包括zh-CN简体中文和zh-TW正体中文 |
06 | header( "Location: /yourpage.html" ); |
07 | //这句代码是将用户转向到根目录的yourpage.html这里 |
08 | exit ; |
09 | //然后退出 |
10 | } |
[代码] [PHP]代码
1 | <?php |
2 | // http://blog.ddian.cn |
3 | $language = substr ( $_SERVER [ 'HTTP_ACCEPT_LANGUAGE' ],0,2); |
4 | if ( $language == 'zh' ){ |
5 | echo '<noscript><noscript>' ; |
6 | } |
7 | ?> |
8 | </body> |