【发布时间】:2020-07-11 18:09:57
【问题描述】:
我目前正在重写我的一个旧 Web 应用程序的 url,我想知道是否可以重写 rss 提要中的链接。
我目前有这个出站重写规则。问题是,如果我在 filterbytags 中添加链接,则不会发生任何事情,因为据我所知,url 不是 href 属性。
<rule name="OutboundShowPost" preCondition="ResponseIsXml1">
<match filterByTags="Link" pattern="^(.*/)pages/frontend/forum/showpost\.aspx\?forum=([^=&]+)&(?:amp;)?post=([^=&]+)$" />
<action type="Rewrite" value="{R:1}forum/{R:2}/post/{R:3}" />
</rule>
我在 aspx 文件中生成的 xml 内容如下所示:
<rss version="2.0">
<channel>
<title>test title</title>
<link>https://example.com</link>
<description>test description</description>
<ttl>5</ttl>
<item>
<title>test title</title>
<description>test description</description>
<link>https://example.com/pages/frontend/forum/showpost.aspx?forum=other&post=&page=1#msg-17</link>
<pubDate>Tue, 26 May 2020 13:41:18 GMT</pubDate>
</item>
</channel>
</rss>
是否可以重写链接标签之间的 url,或者我必须生成已经重写的链接?我想避免这种情况,因为这会使 urlrewrite 碎片化,我更喜欢将它全部放在一个地方。
如果我将 rss 提要链接生成为这样的 href,它可以工作,但这是违反标准的,尽管一些 rss 读者仍然接受我也希望避免这种情况。
<rss version="2.0">
<channel>
<title>test title</title>
<link>https://example.com</link>
<description>test description</description>
<ttl>5</ttl>
<item>
<title>test title</title>
<description>test description</description>
<link href="https://example.com/pages/frontend/forum/showpost.aspx?forum=other&post=&page=1#msg-17" />
<pubDate>Tue, 26 May 2020 13:41:18 GMT</pubDate>
</item>
</channel>
</rss>
【问题讨论】:
-
"我必须生成已经重写的链接吗?"是的,就像任何其他典型的 Web 应用程序(WordPress 等等)一样。
-
URL 重写仅支持重写 html 标签中的特定属性。 IIS 不支持在 和 之间重写内容。所以你必须找到另一种方法来实现这一点。
标签: iis rss url-rewrite-module web-application-project