,我该如何例外HTTPS例外
我的htaccess文件中有几个规则。在一个块中,我将行为更改为HTTPS,无论如何,下一个块,我将定义一个异常
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L]
# but not SOAP or APP-calls #
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{QUERY_STRING} ^type=8800882$
RewriteCond %{QUERY_STRING} (.*(?:^|&))action=.*
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L]
</IfModule>
第一个块可以做到。但是,不可能将HTTP强制使用setage parameter" type = 8800882"或向请求添加参数操作。
这是我的第二次尝试,首先是我这样做(工作,但现在被打破了):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# all should be HTTPS #
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{QUERY_STRING} !^type=8800882$
RewriteCond %{QUERY_STRING} !(.*(?:^|&))action=.*
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L]
</IfModule>
如果有参数类型= 8800882或参数Action =*?
您可以使用以下规则:
RewriteEngine on
#exclude /?action=.* and ?type=8800882
RewriteCond %{THE_REQUEST} !?(?:type=8800882|action=.*) [NC]
#http to https
RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) https://%{HTTP_HOST}/$1 [NE,L,R]