302 HTTP重定向到移动子域的示例?

时间:2015-04-16 13:27:03

标签: redirect mobile subdomain

有没有人有关于如何将移动用户重定向到像m.example.com这样的子域的实际示例?我知道这最好是通过302 HTTP重定向完成,但我还没有遇到一个实际的例子。

我假设您正在寻找客户解决方案?

修改

我刚刚在某个地方找到了这个。它适用于wordpress,但我认为它可以适用于任何网站

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

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]

0 个答案:

没有答案