【发布时间】:2015-12-08 21:48:26
【问题描述】:
我正在使用 .htaccess 使用此处找到的代码重定向手机 RewriteCond to exclude a path not working 我尝试重写排除路径的部分以排除 URL,但无法使其正常工作。 基本上,我在我的主机帐户上使用了第二个 url,它是一个插件域,存储在我的公共 html 文件夹的子文件夹中。我的其他网站存储在公共 html 文件夹中,带有 .htaccess 以重定向到该网站的移动子域。
关于如何阻止插件域重定向到主网站的移动版本有什么建议吗?
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# Check if mobile=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$)
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST}]
# Check if mobile=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST}]
# Skip next rule if mobile=0 [OR] if it's a file [OR] if /path/
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$) [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_URI} ^.*/path/.*$
RewriteRule ^ - [S=1]
# Check if this looks like a mobile device
RewriteCond %{HTTP_PROFILE} !^$ [OR]
RewriteCond %{HTTP_X_WAP_PROFILE} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE} !mobile=0(;|$)
# Don't redirect "path" pages
RewriteCond %{REQUEST_URI} !^.*www.addondomain.com/.*$ [NC]
# Now redirect to the mobile site
RewriteRule ^ http://m.example.com/ [R,L,NC]
【问题讨论】:
-
您需要向我们提供您尝试过的实际代码。到目前为止,您的问题只是猜测
-
好的,刚刚添加了我尝试过的当前代码。已经尝试了几个不同版本的 www.addondomain.com 在那个空间中安装