【发布时间】:2014-02-21 02:12:13
【问题描述】:
我需要将rel="nofollow" 属性添加到其href 属性值与定义的模式匹配的所有<a> 标记。
我认为可以使用 IIS Url Rewrite 模块执行此操作,使用带有自定义标记重写的出站规则将值分配给 rel 属性。规则如下所示:
<rule name="Shop url rewrite" preCondition="ResponseIsHtml">
<match filterByTags="CustomTags" customTags="Anchor rel attribute" pattern="^$" />
<action type="Rewrite" value="nofollow" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
<customTags>
<tags name="Anchor rel attribute">
<tag name="a" attribute="rel" />
</tags>
</customTags>
但是,由于现有标签没有 rel 属性,因此规则没有可匹配的内容,因此不会发生任何事情。
有谁知道是否可以使用这种技术将不存在的属性添加到标签中?
【问题讨论】:
标签: asp.net .net iis url-rewrite-module