虚拟主机Web.config 301 设置http跳转https

  • 来源:网络
  • 更新日期:2022-01-20

摘要:RewriteEngine OnRewriteCond %{HTTPS} !=onRewriteRule ^(.*)https://%{SERVER_NAME}/$1[R,L]<rewrite> <rules> <rule name="http redirect to https" stopProcessing="tr

RewriteEngine On


RewriteCond %{HTTPS} !=on


RewriteRule ^(.*)https://%{SERVER_NAME}/$1[R,L]


<rewrite>

<rules>

<rule name="http redirect to https" stopProcessing="true">

<match url="(.*)" />

<conditions>

<add input="{HTTPS}" pattern="^OFF$" />

<add input="{HTTPS_HOST}" pattern="^(localhost)" negate="true" />

</conditions>

<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />

</rule>

</rules>

</rewrite>