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

时间:2022-04-09 08:59:10

在项目的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>标签下面。

其他不用配置