【问题标题】:How do can I code a rewrite rule in IIS 8 so that all traffic points to https://www.*.com from http://*.com?如何在 IIS 8 中编写重写规则,以便所有流量从 http://*.com 指向 https://www.*.com?
【发布时间】:2015-08-26 06:03:03
【问题描述】:

我有以下人们可以访问的根级 URL:

1. http://example.com
2. http://www.example.com
3. https://example.com
4. https://www.example.com

如何使用 IIS 8 中的重写规则确保 1、2 和 3 始终重定向到 4?当然,它应该保留附加的任何辅助信息(例如/images/myfile.jpg?query=string&another=string

【问题讨论】:

    标签: url redirect iis ssl url-rewriting


    【解决方案1】:

    你可以试试这个规则

    <rewrite>
      <rules>        
        <rule name="example.com to www.example.com" enabled="true" stopProcessing="true">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAny">
            <add input="{HTTP_HOST}" pattern="www.example.com" negate="true" />
            <add input="{HTTPS}" pattern="off" />
          </conditions>
          <action type="Redirect" url="https://www.example.com/{R:1}"
                  redirectType="Permanent" />
        </rule>
      </rules>
    <rewrite>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-28
      • 2015-08-12
      • 1970-01-01
      • 2016-05-08
      • 2018-02-02
      • 1970-01-01
      • 2015-08-10
      • 2019-11-15
      相关资源
      最近更新 更多