.htaccess重定向到移动版本问题

时间:2013-12-18 22:24:50

标签: apache .htaccess redirect mobile

我在尝试之前试图解决这个问题,但是无法解决这个问题,这是我所拥有的。

基本上我在一个主机帐户上有两个网站。两个网站都有自己的域名,例如: www.website1.com www.website2.com

网站1转到根文件夹以获取网站信息(index.htm等)

网站2位于子目录中 / WEBSITE2 /

网站1已经有一个移动版avalabile: www.mobile.website1.com

网站2是一个新网站,我还没有开发该网站的移动版本。但问题是如果您在移动设备上,根文件夹中的ht访问权限会将任何内容重定向到第一个站点的移动版本。

因此,例如,如果我想通过手机访问网站2,我将转到网站1的移动版本。

任何人都可以看到我的问题和帮助吗?就像我说我试图在其他地方找到解决方案但没有运气并检查所有以前的问题。

##BEGIN MOBILE (do not edit below this line)
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ((.*iPhone.*)|(.*iPod.*)|(.*BlackBerry.*)|(.*Android.*Mobile.*)|(.*Windows\ CE.*)|(.*IEMobile.*)|(.*Opera\ Mini.*)|(.*Opera\ Mobi.*))
RewriteCond %{HTTP_COOKIE} !dm_show_classic
RewriteCond %{QUERY_STRING} !no_redirect=true [NC]

RewriteCond %{HTTP_HOST} ^www\.website1\.com [NC]
RewriteRule ^(.*)$ http://mobile.website1.com/ [L]

RewriteCond %{HTTP_HOST} ^www\.website2\.com [NC]
RewriteRule ^(.*)$ http://www.website2.com [L]
RewriteBase /
##END MOBILE

1 个答案:

答案 0 :(得分:0)

我试过这个并为我工作:

##BEGIN MOBILE (do not edit below this line)
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ((.*iPhone.*)|(.*iPod.*)|(.*BlackBerry.*)|(.*Android.*Mobile.*)|(.*Windows\ CE.*)|(.*IEMobile.*)|(.*Opera\ Mini.*)|(.*Opera\ Mobi.*))
RewriteCond %{HTTP_COOKIE} !dm_show_classic
RewriteCond %{QUERY_STRING} !no_redirect=true [NC]

RewriteCond %{HTTP_HOST} ^www\.website1\.com [NC]
RewriteRule ^(.*)$ http://mobile.website1.com/ [L]

RewriteCond %{HTTP_USER_AGENT} ((.*iPhone.*)|(.*iPod.*)|(.*BlackBerry.*)|(.*Android.*Mobile.*)|(.*Windows\ CE.*)|(.*IEMobile.*)|(.*Opera\ Mini.*)|(.*Opera\ Mobi.*))
RewriteCond %{HTTP_COOKIE} !dm_show_classic
RewriteCond %{QUERY_STRING} !no_redirect=true [NC]

RewriteCond %{HTTP_HOST} ^www\.website2\.com [NC]
RewriteRule ^(.*)$ http://www.website2.com [L]
RewriteBase /
##END MOBILE