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

1 Answer 1

0
+50

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.

2
  • 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 8, 2011 at 10:19
  • btw, I edited my post since I just noticed that my * * turned into markup. The updated syntax is correct. Feb 8, 2011 at 17:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .