【问题标题】:Exclude Development URL from IIS rewriting rule从 IIS 重写规则中排除开发 URL
【发布时间】:2020-05-11 15:16:09
【问题描述】:

我有一个 IIS URL - 重写规则,确保所有 url 都有 www。 -

<rule name="Add www" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="www.example.com" negate="true" />
          </conditions>
          <action type="Redirect" url="https://www.example.com/{R:1}" />
</rule>

这在生产中按我想要的方式工作。

但是我在我的开发机器上设置了一个本地版本的网站,看起来像 http://mydomain.local

当我运行本地版本的网站并转到 mydomain.local 时,我会被重定向到 www.example.com

如何让规则忽略我的本地开发 URL?

【问题讨论】:

  • 在此之上添加一条规则以对“mydomain.local”不执行任何操作,或添加另一个条件以执行相同操作。
  • @LexLi 怎么样?可以发个例子吗

标签: iis url-rewriting url-routing iis-7.5 url-rewrite-module


【解决方案1】:

可以尝试添加条件忽略本地开发URL。

<rule name="Add www" patternSyntax="Wildcard" stopProcessing="true">
      <match url="*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="www.example.com" negate="true" />
        <add input="{HTTP_HOST}" pattern="http://mydomain.local" negate="true" />
      </conditions>
      <action type="Redirect" url="https://www.example.com/{R:1}" />
</rule>

最好的问候,

山姆

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-27
    • 1970-01-01
    • 2014-05-01
    • 2014-06-27
    • 2021-08-04
    • 1970-01-01
    相关资源
    最近更新 更多