【发布时间】:2012-01-26 21:27:00
【问题描述】:
我有一个非常简单的 OutBound UrlRewriter 规则,它重写它在 http 响应流的正文中找到的 url:
<rewrite>
<outboundRules>
<rule name="Scripted"
preCondition="IsHtml"
patternSyntax="ECMAScript"
stopProcessing="false">
<match filterByTags="None" pattern="http://someurl.com" />
<action type="Rewrite" value="http://anotherurl.com" />
</rule>
<preConditions>
<preCondition name="IsHtml" patternSyntax="Wildcard">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
问题是只要我打开preCondition 就不会发生重写。
我需要能够使用前置条件,因为该页面是 ASP.NET 页面并使用 ASP.NET 脚本资源,例如<script src="ScriptResource.axd?d=...." type="text/javascript" />。
默认情况下,脚本资源是 gzip 压缩的,我想保持这种方式。如果没有内容类型前提条件,URL 重写器RewriteModule 会抛出 500.52 错误 - “当 HTTP 响应的内容被编码(“gzip”)时,无法应用出站重写规则。”
使用 Fiddler 我可以看到 Content-Type: text/html; charset=utf-8 正在响应标头中发送,但 UrlRwriter 似乎无法匹配。
为什么会这样?
【问题讨论】:
标签: iis-7 url-rewriting urlrewriter