且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

简单的IIS URL重写

更新时间:2023-02-24 11:31:41

以下网址重写规则应该符合您的要求:

The following URL rewrite rule should do what you want:

<rewrite>
    <rules>
        <rule name="Redirect to port 444" stopProcessing="true">
            <match url="(.*)" />
            <conditions logicalGrouping="MatchAny">
                <add input="{HTTPS}" pattern="^ON$" negate="true" />
                <add input="{SERVER_PORT}" pattern="^444$" negate="true" />
            </conditions>
            <action type="Redirect" url="https://sub.corp.com:444/{R:0}" />
        </rule>
    </rules>
</rewrite>

重定向到 https://sub.corp.com:444 每当HTTPS未开启或端口号不是444时。该站点应绑定到端口80(带HTTP),443(带有用于标准的HTTPS(SSL)en 444(使用HTTPS)可以使其工作。

It redirects to https://sub.corp.com:444 whenever HTTPS is not ON or when the port number is not 444. The site should have bindings to port 80 (with HTTP), 443 (with HTTPS for standards SSL) en 444 (with HTTPS) for this to work.