我有个问题。在reading all of this post之后,我试图只为那些不支持现代浏览器功能的WAP设备实现一个重定向。
例如,我想让一台旧的BlackBerry使用这个重定向,而不是安卓或iPhone设备。
RewriteEngine On
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP:Profile} !^$
RewriteCond %{REQUEST_URI} !^/wap/?$
RewriteRule ^ http://example.com/wap/ [R,L]问题是该规则会重定向所有移动设备。不管怎样,我能解释一下现代浏览器吗?
谢谢!
发布于 2015-01-13 23:30:58
这将工作,我使用我的wordpress网站,以重定向到我的移动网站m.mysite.com
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
# prevent looping
RewriteCond %{HTTP_HOST} !^m.mysite.com$
# if the browser accepts these mime-types, it's definitely mobile, or pretending to be
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR]
# a bunch of user agent tests
RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC]
# rewrite rules here
RewriteRule ^(.+)\$ http://m.mysite.com/$1 [R=302,NC] 如果需要,您可能需要修改某些部分。
https://stackoverflow.com/questions/27924792
复制相似问题