1. <?php
  2. error_reporting(E_ALL^E_NOTICE);

  3. //分析HTTP_ACCEPT_LANGUAGE的屬性
  4. //這裡只取第一語言設置(其他可根據需要增強功能,這裡只做簡單的方法演示)

  5. preg_match('/^([a-z\-]+)/i',$_SERVER['HTTP_ACCEPT_LANGUAGE'],$matches);
  6. $lang=$matches[1];

  7. switch($lang){
  8.        case'zh-cn':
  9.            header('Location:http://cn.example.com/');
  10.            break;
  11.        case'zh-tw':
  12.            header('Location:http://tw.example.com/');
  13.            break;
  14.        case'ko':
  15.            header('Location:http://ko.example.com/');
  16.            break;
  17.        default:
  18.            header('Location:http://en.example.com/');
  19.            break;
  20. }

  21. ?>

複製代碼

arrow
arrow
    全站熱搜

    jianmin2 發表在 痞客邦 留言(0) 人氣()