0

I have a very simple OutBound UrlRewriter rule that rewrites url's it finds in the body of the http response stream:

<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>

The problem is that as soon as I turn on the preCondition no rewriting takes place.

I need to be able to use a pre-condition because the page is an ASP.NET page and uses ASP.NET script resources e.g. <script src="ScriptResource.axd?d=...." type="text/javascript" />.

By default script resources are gzip compressed and I want to keep them that way. Without the content type precondition the URL rewriter RewriteModule throws a 500.52 error - "Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded ("gzip")."

Using Fiddler I can see that Content-Type: text/html; charset=utf-8 is being sent in the response header but UrlRwriter seems unable to match this.

Why is this happening?

4

1 回答 1

3

这是因为服务器变量HTTP_ACCEPT_ENCODING未添加到允许的服务器变量列表中。将其添加到那里(您可以在 IIS 中搜索如何添加)。

于 2012-01-26T13:23:49.633 回答