【问题标题】:Using IIS Url Rewrite from HTTPS to another HTTPS使用 IIS Url Rewrite 从 HTTPS 到另一个 HTTPS
【发布时间】:2013-11-01 15:15:48
【问题描述】:

我正在尝试将我的网站从 https://localhost(但使用 ip 编写,例如 https://10.0.7.8)重定向到另一个 https 位置,例如 https://mysite.com

我目前的配置是:

<rewrite>
  <rules>
    <rule name="Rewrite to mysite.com" enabled="true" stopProcessing="true">
      <match url="(.*)" />
      <action type="Redirect" url="https://mysite.com/{R:0}" redirectType="Permanent" />
      <conditions logicalGrouping="MatchAll">
        <add input="{HTTP_HOST}" pattern="https://10.0.7.8*" />
      </conditions>
     </rule>
  </rules>
</rewrite>

当我访问https://10.0.7.8 时,它不会转到https://mysite.com,而是停留在https://10.0.7.8

知道我做错了什么吗?

【问题讨论】:

    标签: c# iis url-rewriting web-config


    【解决方案1】:

    您需要在 2 个条件下将https 部分从 ip 中拆分出来:

    <rewrite>
      <rules>
        <rule name="Rewrite to mysite.com" enabled="true" stopProcessing="true">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" pattern="^10\.0\.7\.8$" />
            <add input="{HTTPS}" pattern="^ON$" />
          </conditions>
          <action type="Redirect" url="https://mysite.com/{R:0}" redirectType="Permanent" />
         </rule>
      </rules>
    </rewrite>
    

    另外,10.0.7.8 需要写成10\.0\.7\.8,因为. 需要转义,因为它是一个特殊字符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-13
      • 1970-01-01
      • 1970-01-01
      • 2021-02-06
      • 2018-02-13
      • 2020-10-17
      • 2016-03-20
      • 2012-02-28
      相关资源
      最近更新 更多