C# Azure-让http自动跳转到https链接

时间:2023-03-08 17:38:17

在项目的web.config下面加上下面的配置:

    <rewrite>
<rules>
<clear />
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>

此节点,在<system.webServer>标签下面。

其他不用配置