Exclude path in IIS rewrite rule?

13,193

You could do something such as:

    <rules>
        <rule name="LowerCaseRule1" stopProcessing="true">
            <match url="[A-Z]" ignoreCase="false" />
             <conditions>
              <add input="{URL}" negate="true" pattern="^~/myfolder$" />
             </conditions>
            <action type="Redirect" url="{ToLower:{URL}}" />
        </rule>
    </rules>

or... you could create another rule that does essentially the opposite for the specific match:

    <rules>
        <rule name="LowerCaseRule2" stopProcessing="false">
            <match url="^~/myfolder$" ignoreCase="true" />
            <action type="None" />
        </rule>
    </rules>
Share:
13,193
TruMan1
Author by

TruMan1

Updated on June 04, 2022

Comments

  • TruMan1
    TruMan1 almost 2 years

    I have a rewrite rule that converts a URL to lowercase. I would like to exclude a folder but don't know RegEx. How do I exclude "~/myfolder" from the rule below?

      <rewrite>
            <rules>
                <rule name="LowerCaseRule1" stopProcessing="true">
                    <match url="[A-Z]" ignoreCase="false" />
                    <action type="Redirect" url="{ToLower:{URL}}" />
                </rule>
            </rules>
        </rewrite>