2

I know how to canonicalise the case of URLs on incoming request to IIS7.5, in fact, there's a built in rule template to start from. But how about outbound (without changing the code)?

This is where I got to so far:

    <outboundRules>
        <rule name="Outbound lowercase" preCondition="IsHTML" enabled="true">
            <match filterByTags="A" pattern="[A-Z]" ignoreCase="false" />
            <action type="Rewrite" value="{ToLower:{R:0}}" />
        </rule>
        <preConditions>
            <preCondition name="IsHTML">
                <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
            </preCondition>
        </preConditions>
    </outboundRules>

However, IIS barfs on the action with a 500 implying an invalid web.config, probably on the {ToLower:XXXX} which I stole from the MS-supplied inbound rule template.

Anyone know how to do this?

Anyone know where the options are fully documented (my GoogleNinja skills failed me: I found this but "Specifies value syntax for the rule. This element is available only for the Rewrite action type" is not really comprehensive).

Thanks, Damian

DDM
  • 240
  • 2
  • 12

1 Answers1

0

This rule works for me without any errors. The only change to make is with the pattern. Change it from "[A-Z]" to ".*[A-Z].*" so that the replaced value is the entire string and not just the first upper case letter.

As for way you get the syntax error, do you have the outbound rule wrapped within the section? And, check to make sure that you have url rewrite 2.0 installed. Outbound rules were added in v2.0.

Scott Forsyth
  • 16,339
  • 3
  • 36
  • 55
  • Hmm, that is interesting. It's IIS7.5 on 2008R2 so it should be the latest URL Rewrite. Will test again and let you know. – DDM Feb 08 '11 at 10:19
  • btw, I edited my post since I just noticed that my * * turned into markup. The updated syntax is correct. – Scott Forsyth Feb 08 '11 at 17:33