windows server网站 IIS http自动跳转https

在web.config文件中 system.webServer 节点下配置下面代码即可

<rewrite>
    <rules>
        <rule name = "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}:443/{R:1}" redirectType="SeeOther" />
        </rule>
    </rules>
</rewrite>

本文来自 www.luofenming.com