【问题标题】:IIS redirect only one domain on SSLIIS 在 SSL 上仅重定向一个域
【发布时间】:2017-06-02 15:28:33
【问题描述】:

我在 IIS 上有一些网站是 http,但现在我添加了 SSL,但仅适用于一个域。但是我有很多指向同一个网站的自定义域,这就是我需要的

www.example.comexample.com 的 ssl,但我也有 www.examplenew.com、www.example34.com、example56 .com 指向同一个网站,但我没有 ssl,我只需要重写 www.example.com 和 example.com 的规则,其他我不需要。 我在 web.config 中制定了重写规则,用于重定向到 https 但知道它的重定向全部到 ssl 我不需要,这是我的 web.config 文件

 <rewrite>
      <rules>
        <rule name="HTTP to HTTPS redirect" stopProcessing="true">
          <match url="(*)" />
            <conditions>
              <add input="{HTTPS}" pattern="off" ignoreCase="true" />
            </conditions>
            <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
        </rule>
      </rules>
    </rewrite>

【问题讨论】:

    标签: mod-rewrite iis


    【解决方案1】:

    你需要添加一个额外的条件来重写规则,它将检查主机:

    <rules>
        <rule name="HTTP to HTTPS redirect" stopProcessing="true">
            <match url="(.*)" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="^(www.)?example.com" />
                <add input="{HTTPS}" pattern="off" ignoreCase="true" />
            </conditions>
            <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
        </rule>
    </rules>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-06
      • 2013-08-04
      • 2020-10-01
      • 2014-09-18
      • 1970-01-01
      • 1970-01-01
      • 2012-12-21
      • 1970-01-01
      相关资源
      最近更新 更多