iis - IIS URL Rewrite 删除部分路径
问题描述
在研究了 url rewrite 并查看了许多帖子之后,我仍然对为什么我的 url rewrite 不起作用感到困惑。我正在尝试/carrot/
从路径中删除。
前任:https://my.server.com/carrot/mobile/path
应该变成:https://my.server.com/mobile/path
我的 URL 重写规则非常简单,如下所示:
<rule name="RemoveCarrotFromPath">
<match url=".*carrot(.*)" />
<action type="Rewrite" url="{R:1}" />
</rule>
感谢所有帮助。
编辑您可以在下面找到所有正在使用的规则,以防这是各种规则发生冲突的问题:
<rewrite>
<rules>
<rule name="redirectPayment" stopProcessing="true">
<match url="/payment" />
<action type="Redirect" url="https://my.app.com/carrot/Payment" />
</rule>
<rule name="redirectMembership" stopProcessing="true">
<match url="/membership" />
<action type="Redirect" url="https://my.app.com/carrot/Membership" />
</rule>
<rule name="RemoveCarrotFromPath">
<match url=".*carrot(.*)" />
<action type="Rewrite" url="{R:1}" />
</rule>
</rules>
</rewrite>
解决方案
我的问题的解决方案是使用Redirect
而不是Rewrite
如下:
<rule name="RemoveCarrotFromPath">
<match url=".*carrot(.*)" />
<action type="Redirect" url="{R:1}" />
</rule>
推荐阅读
- javascript - 一天几小时前的时刻
- python - 了解 Map Reduce - 以下代码中的工作流程
- flask - 绑定到所有接口有什么问题,有哪些替代方法?
- java - 在 Jboss 服务器中将 Hibernate 从 3 升级到 4 (WildFly 18.x)
- python - 如何在 Airflow 中一次运行两次相同的 dag
- node.js - NODE JS、PM2 和 Nginx - 创建 JWT 令牌时出现 502 Bad Gateway
- python - 我将如何解决这个“if”语句错误?
- slack - 你能以非交互方式使用松弛按钮吗?
- c++ - 在重载的 I/O 运算符中通过引用传递和返回 I/O 流
- angular - 如何修复 CVE-2020-7663 | CVSS 评分:7.5 漏洞