首页 > 解决方案 > IIS 重写 - 匹配 URL 覆盖

问题描述

我正在尝试设置一些 301 重定向,但是我遇到了匹配 URL 语句的问题。

这是我的 IISUrlRewrite.xml 文件:

<rewrite>
  <rules>
    <rule name="CAS to PAS" stopProcessing="true">
      <match url="/call-answering-service" />
      <action type="Redirect" url="/us/phone-answering-service" redirectType="Permanent" appendQueryString="true" />
    </rule>
    <rule name="PAS tp CAS lp" stopProcessing="true">
      <match url="/us/lp/phone-answering-service" />
      <action type="Redirect" url="/us/lp/call-answering-service" redirectType="Permanent" appendQueryString="true" />
    </rule>
  </rules>
</rewrite>

所以第一个重定向https://localhost:5001/us/call-answering-service/ 应该重定向到https://localhost:5001/us/call-answering-service/ 这个工作正常,但是,第二个重定向生活在

https://localhost:5001/us/lp/phone-answering-service/重定向到https://localhost:5001/us/phone-answering-service而不是https://localhost:5001/us/lp/call-answering-service/

我假设这导致它与 URL 匹配的第一条规则包含 /call-answering-service 在它被第二条规则重定向并命中第一条规则之后。有没有办法让我更明确?

谢谢

标签: asp.netasp.net-coreiis

解决方案


推荐阅读