在 IIS 重写规则中排除路径? [英] Exclude path in IIS rewrite rule?

查看:24
本文介绍了在 IIS 重写规则中排除路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个将 URL 转换为小写的重写规则.我想排除一个文件夹,但不知道 RegEx.如何从下面的规则中排除~/myfolder"?

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>

推荐答案

您可以执行以下操作:

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

这篇关于在 IIS 重写规则中排除路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆