在工作时遇到第一个成功的规则后,如何停止mod_rewrite
?
我尝试使用L
和E
标志的不同组合,但是还没有找到一种方法来做到这一点。
这是.htaccess
我最近的尝试的当前文件
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/(basket|order).html [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L,E=STOP:1]
RewriteCond %{ENV:STOP} !1
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/(basket|order).html [NC]
RewriteRule ^ http://www.example.com%{REQUEST_URI} [R=301,L,E=STOP:1]
RewriteCond %{ENV:STOP} !1
RewriteRule ^(.*).html$ cms.php?pagename=$1 [QSA]
RewriteCond %{ENV:STOP} !1
RewriteRule ^$ cms.php [QSA]
http://www.example.com/basket.html
例如,每次尝试打开时,它会将我重定向到http://www.example.com/cms.php?pagename=basket
。但这是不对的,我只是想从重定向http
到https
。
有如下规则:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} /(basket|order)\.html [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} !/(basket|order)\.html [NC]
RewriteRule ^ http://www.example.com%{REQUEST_URI} [R=301,L]
RewriteRule ^$ cms.php [L]
RewriteRule ^(.+?)\.html$ cms.php?pagename=$1 [L,QSA,NC]
使用THE_REQUEST
的,而不是REQUEST_URI
为你的最后一个规则路由.html
请求cms.php
从而改变值REQUEST_URI
而THE_REQUEST
保持不变。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句