C# 使用IIS Url从HTTPS重写到另一个HTTPS

C# 使用IIS Url从HTTPS重写到另一个HTTPS,c#,iis,url-rewriting,web-config,C#,Iis,Url Rewriting,Web Config,我正在尝试从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="(.*)" /> <a

我正在尝试从
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


知道我做错了什么吗?

您需要在两种情况下从ip中拆分
https
部分:

<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
,因为
是一个特殊字符,需要进行转义