【发布时间】:2016-04-06 20:20:56
【问题描述】:
我的 html 响应中有这样的内容:
<img
src="http://www.test.com/image1.jpg"
srcset="http://www.test.com/image1-300x200.jpg 300w, http://www.test.com/image1.jpg 600w" sizes="(max-width: 600px) 100vw, 600px" />
我想使用 IIS 出站重写规则将所有对 www.test.com 的引用替换为 www.foo.com。当一个属性(在本例中为 srcset)具有多个 URL 实例时,我该怎么做?
这是我的规则目前的样子:
<outboundRules>
<rule name="Blog Paths" preCondition="IsBlog">
<match filterByTags="Img, CustomTags" customTags="BlogTags" pattern="^http://www.test.com(.*)$" />
<action type="Rewrite" value="http://www.foo.com{R:1}" />
</rule>
<preConditions>
<preCondition name="IsBlog">
<add input="{RESPONSE_Content_Type}" pattern="^text/html" />
<add input="{RESPONSE_X_Content_Source}" pattern="^blog" />
</preCondition>
</preConditions>
<customTags>
<tags name="BlogTags">
<tag name="img" attribute="srcset" />
</tags>
</customTags>
</outboundRules>
当然,只有每个属性中的第一个 URL 会被覆盖:
<img
src="http://www.foo.com/image1.jpg"
srcset="http://www.foo.com/image1-300x200.jpg 300w, http://www.test.com/image1.jpg 600w" sizes="(max-width: 600px) 100vw, 600px" />
如何将www.test.com 的所有实例重写为www.foo.com?
【问题讨论】:
标签: iis url-rewriting rewrite outbound