.htaccess 非HTTPS的htaccess重写条件和重写规则
我的htaccess文件中有几个规则。 在任何情况下,对于一个块,我将行为更改为HTTPS,对于下一个块,我将定义一个异常.htaccess 非HTTPS的htaccess重写条件和重写规则,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我的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 # Re
<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>
重新启动发动机
重写基/
重写cond%{SERVER\u PORT}^443$
重写规则(.*)https://%{HTTP_HOST}/$1[L]
#但不是SOAP或应用程序调用
重写cond%{SERVER_PORT}^443$
RewriteCond%{QUERY_STRING}^type=8800882$
RewriteCond%{QUERY_STRING}(.*(:^ |&))操作=*
重写规则(.*)http://%{http_HOST}/$1[L]
第一个街区就可以了。
但是,通过设置参数“type=8800882”或向请求中添加参数操作来强制HTTP是不可能的
这是我的第二次尝试,首先我做了这个(工作了,但现在坏了):
重新启动发动机
重写基/
#所有都应该是HTTPS#
重写cond%{SERVER\u PORT}^443$
重写cond%{QUERY_STRING}^类型=8800882$
重写cond%{QUERY_STRING}!(.*(:^ |&))操作=*
重写规则(.*)https://%{HTTP_HOST}/$1[L]
如果存在参数type=8800882或参数action=*?您可以使用以下规则,那么如何对非HTTPS进行例外处理:
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]
您可以使用以下规则:
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]