代码如下
需要加到程序哪里呢。加到index.php中吗
$siteUrl = 'http://'.$_SERVER['HTTP_HOST'].'/'; // 判断访问来源 function UserAgent() { $user_agent = (!isset($_SERVER['HTTP_USER_AGENT'])) ? false : $_SERVER['HTTP_USER_AGENT']; return $user_agent; }
// 跳转相应目录 if ((preg_match("/(iphone|ipad|ipod|android)/i", strtolower(UserAgent()))) AND strstr(strtolower(UserAgent()), 'webkit')) { header('Location: ' . $siteUrl . '3g/'); exit; } if (trim(UserAgent()) == '' OR preg_match("/(nokia|sony|ericsson|mot|htc|samsung|sgh|lg|philips|lenovo|ucweb|opera mobi|windows mobile|blackberry)/i", strtolower(UserAgent()))) { header('Location: ' . $siteUrl . ''); exit; } |