我正在重写规则。对移动网站的每一次呼叫都应该被重定向到非移动版本(或者在我的例子中,是谷歌),除了几页之外。这必须在几个环境中工作,但它们不是问题(据我所见)。
我所拥有的:
RewriteCond %{HTTP_HOST} m\.(local\.|lcl\.|dvl\.|uat\.|)testsite\.be$
RewriteCond %{REQUEST_URI} !^/categoryOne
RewriteCond %{REQUEST_URI} !^/categoryTwo
RewriteRule (.*) http://www.google.be/ [L,R=301]如果我冲浪到:http://m.lcl.testsite.be/categoryOne,我被重定向..。尽管http://htaccess.madewithlove.be/说我不应该。
所以我简化了:
RewriteCond %{REQUEST_URI} !^/categoryOne
RewriteRule (.*) http://www.google.be/ [L,R=301]http://m.lcl.testsite.be/categoryOne
->我被重定向了
RewriteCond %{REQUEST_URI} ^/categoryOne
RewriteRule (.*) http://www.google.be/ [L,R=301]http://m.lcl.testsite.be/categoryOne
我被重定向了(这很好)。
http://m.lcl.testsite.be/randomOtherCategory
->,我不会被重定向。
对我来说,否定的语句似乎被忽略了,这很奇怪,因为我在项目的其他地方使用过它。
有洞察力吗?
发布于 2015-06-10 10:44:14
.htaccess中可能有其他规则将REQUEST_URI更改为其他规则,并导致基于否定的条件传递。
试一试:
RewriteCond %{THE_REQUEST} !/categoryOne
RewriteRule ^ http://www.google.be/ [L,R=301]THE_REQUEST变量不会在其他规则之后更改其值。
https://stackoverflow.com/questions/30753222
复制相似问题