Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted
+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.

share|improve this answer
    
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. –  Quog Feb 8 '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 - MVP Feb 8 '11 at 17:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.