【发布时间】:2020-07-02 00:20:47
【问题描述】:
我一直在尝试寻找一些关于如何执行 URL 重写的附加信息,其中预期的输出是删除/替换部分 url。
例如,我想确保我的所有锚标记的 href 值都会被修改。
<a class="button" href="https://www.oldgoogle.com" target="_blank">
<a class="button" href="https://www.oldgoogle.com/links" target="_blank">
<a class="button" href="https://www.oldgoogle.com/links/category?dosearch=true" target="_blank">
<a class="button" href="https://oldgoogle.com/nowww" target="_blank">
使得href值变成这样:
<a class="button" href="https://newgoogle.com" target="_blank">
<a class="button" href="https://newoogle.com/links" target="_blank">
<a class="button" href="https://newgoogle.com/links/category?dosearch=true" target="_blank">
<a class="button" href="https://newgoogle.com/nowww" target="_blank">
请注意,我实际上是在 从网址中删除 www,并将 oldgoogle 替换为 newgoogle。
这是我迄今为止尝试过的:
<rewrite>
<outboundRules>
<remove name="Strip WWW from Anchor Tags" />
<rule name="Strip WWW from Anchor Tags" preCondition="IsHTML">
<match filterByTags="A" pattern="^http(s)://www.oldgoogle.com/(.*)" />
<conditions />
<action type="Rewrite" value="https://newgoogle.com/{R:1}" />
</rule>
</outboundRules>
</rewrite>
感谢您分享解决此问题的任何信息。
附:我们无法修改来自源的链接,因为这些链接都散落在外部文本文件、数据库表和其他源的网络中,并且一些硬编码规则按原样编写链接。所以我唯一的选择是重写应用程序生成和发出的链接。
【问题讨论】:
标签: url iis url-rewriting iis-7