【问题标题】:Looking for redirect to specific domains only仅寻找重定向到特定域
【发布时间】:2019-07-10 14:47:48
【问题描述】:

我是新的 IIS,但遇到的情况并非我们所有的客户都在他们的网站上使用 ssl,但有一些人使用。因此这里的问题是,启用重定向后,当它重定向到启用 ssl 的页面时,它运行良好,但在非 ssl 网站上会发出 ssl 警告。

我想添加一些重定向规则: 1. 仅在我允许的域上使用 https 重定向。 2. 仅针对不在允许列表中的站点使用 http 重定向。

对此的任何帮助将不胜感激。

谢谢, 拉斯图。

【问题讨论】:

  • 添加条件以检查传入请求的主机名。 Google 上有大量示例。

标签: url-rewriting iis-7 url-redirection http-redirect


【解决方案1】:

正如 lex 所说,我们可以使用 url rewrite 的条件来满足您的要求。您可以将此 url rewrite 规则放在网站中。

注意:条件的 HTTP_HOST 应该设置不启用 SSL 的域。

        <rules>
           <rule name="HTTP to HTTPS on different SSL Port" enabled="true" stopProcessing="true">
            <match url="(.*)" ignoreCase="true"  negate="false" />
             <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
                <add input="{HTTPS}" pattern="off" />
                <add input="{HTTP_HOST}" pattern="^www.domainwithoutusingSSL.com$" negate="true"/>
           <add input="{HTTP_HOST}" pattern="^www.domainwithoutusingSSL2.com$" negate="true"/>
            </conditions>
            <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="true" />
        </rule>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-03
    • 2010-12-06
    • 2016-06-10
    • 2018-02-15
    • 2017-08-16
    • 2016-03-30
    相关资源
    最近更新 更多