User-Agent用法一:检测手机访问
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|palmos|webos|UCBrowser|QQBrowser|wap" [NC]
RewriteRule ^$ 要跳的页面 [R=301,L]
User-Agent
支持通配符号*(匹配任意字符串)和多个值。例子:curl|IE|chrome|firefox(多个值用|分割)
代码中做判断
if(preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])){
if($_SERVER['HTTP_HOST']=='www.11meeting.cn'){
header('Location: http://m.11meeting.cn'.$_SERVER['REQUEST_URI']);
exit;
}
}