重定向移动设备使用的

重定向移动设备使用的

本文介绍了重定向移动设备使用的.htaccess //排除IPAD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个code在我的.htaccess重定向移动设备。此刻iPad也移动装置。我怎样才能改变这一点,所以iPad不是重定向到一个移动版本?

感谢您!

  RewriteEngine叙述上
的RewriteBase /
#检查,如果这是noredirect查询字符串
的RewriteCond%{QUERY_STRING}(^ |&安培;)M = 0(安培; | $)
#设置一个cookie,并跳过下一条规则
重写规则^  -  [CO = mredir:0:www.website.com]

#检查,这看起来像一个移动设备
#(你可以添加另一个[OR]为第二个,加入你
#不得不检查,但我相信大多数移动设备应该发送的
#至少这头之一)
的RewriteCond%{HTTP:X-WAP瞩目} ^ $ [OR]!
的RewriteCond%!{HTTP:档案} ^ $ [OR]
的RewriteCond%{HTTP_USER_AGENT}ACS | alav | ALCA |夏新|奥迪| ASTE |阿万|明基|鸟| BLAC | blaz | BREW |电池| CLDC | CMD-[NC,OR]
的RewriteCond%{HTTP_USER_AGENT}宕|多科|埃里克| HIPT | INNO | iPAQ的|的Java |夹具| KDDI |克己|纱罗| LG-C | LG-D | LG-G | lge-[NC,OR]
的RewriteCond%{HTTP_USER_AGENT}毛伊岛| maxo | MIDP | MITS | MMEF | MOBI | MOT- |摩托| mwbp | nec- |蝾螈| NOKI | OPWV[NC,OR]
的RewriteCond%{HTTP_USER_AGENT}掌|帕纳|七分裤| pdxg |菲尔|游戏| PLUC |口| PROX | QTEK | qwap |鼠尾草| SAMS |三一重工[NC,OR]
的RewriteCond%{HTTP_USER_AGENT}SCH-|节|发送|斯里| SGH- |沙皮|的西门子|暹| SMaL公司| SMAR |索尼| sph- | SYMB | T-MO[NC,OR]
的RewriteCond%{HTTP_USER_AGENT}特立|时序|胡说| tsm- | upg1 | UPSI | VK-V |沃达| w3cs | wap- |水电局| WAPI[NC,OR]
的RewriteCond%{HTTP_USER_AGENT}WAPP | wapr | WEBC | winw | winw | XDA | xda-[NC,OR]
的RewriteCond%{HTTP_USER_AGENT}up.browser | up.link | windowssce | iemobile |迷你| MMP[NC,OR]
的RewriteCond%{HTTP_USER_AGENT}塞班| MIDP | WAP手机|口袋|手机| PDA | PSP[NC]
的RewriteCond%{HTTP_USER_AGENT}!Macintosh的[NC]

#检查,如果我们不是已经在移动网站
的RewriteCond%{HTTP_HOST}!^ M \。
#无法读取和同样的要求写的cookie,必须复制的条件
的RewriteCond%{QUERY_STRING}(^ |&安培)!M = 0(安培; | $)

#检查以确保我们以前没有设置cookie
的RewriteCond%{} HTTP_COOKIE!^ * mredir = 0。* $ [NC]

#现在重定向到移动网站
重写规则^ http://m.website.com [R,L]
 

解决方案

你能在此之前你只要运行这​​个检查移动设备

 的RewriteCond%{HTTP_USER_AGENT} ^ *的iPad。* $
 重写规则^(。*)$ [域名]
 

SRC: http://www.xpertdeveloper.com/2012/02 /检出的iPad-的htaccess /

I use this Code in my .htaccess to redirect mobile devices. At the moment iPad is also a mobile device. How can I change this, so that ipad is not redirected to a mobile version?

Thank you!

RewriteEngine on
RewriteBase /
# Check if this is the noredirect query string
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:www.website.com]

# Check if this looks like a mobile device
# (You could add another [OR] to the second one and add in what you
#  had to check, but I believe most mobile devices should send at
#  least one of these headers)
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP:Profile}       !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT}  "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
RewriteCond %{HTTP_USER_AGENT} !macintosh [NC]

# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^m\.
# Can not read and write cookie in same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$)

# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE}        !^.*mredir=0.*$ [NC]

# Now redirect to the mobile site
RewriteRule ^ http://m.website.com [R,L]
解决方案

Can you not just run this before you check for mobile devices

 RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
 RewriteRule ^(.*)$ [domain-name]

src: http://www.xpertdeveloper.com/2012/02/detect-ipad-htaccess/

这篇关于重定向移动设备使用的.htaccess //排除IPAD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 07:31