如果进入一下网站的首页如果用户在中国 则进入 www.test.cn
如果用户在美国 则进入 www.test.us
如果是其它国家 则进入 www.test.other如果不用IP 分段,还有其它方法吗 请问用什么方法可以实现这个功能

解决方案 »

  1.   

    <?php
    preg_match('/^([a-z\-]+)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches); 
    $lang = $matches[1]; 
    switch ($lang) { 
           case 'zh-cn' : 
                   header('Location: http://www.test.cn'); 
                   break; 
           case 'en-us' : 
                   header('Location: http://www.test.us'); 
                   break; 
           default: 
                   header('Location: http://www.test.other'); 
                   break; 

    ?>