How to Exclude Directories from Rules in Web.config (ASP.NET)

后端 未结 1 373
夕颜
夕颜 2021-01-19 01:19

I have these rules set in my Web.config:

    
        
          

        
相关标签:
1条回答
  • 2021-01-19 02:22

    Based on the following solution here:

    How to exclude a directory with IIS URL rewriting?

    You could do something like this:

    <rules>
        <rule name="ignore web forms folder 1" stopProcessing="true">
            <match url="^webformsfolder1/" />
            <action type="None" />
        </rule>
        <rule name="ignore web forms folder 2" stopProcessing="true">
            <match url="^webformsfolder2/" />
            <action type="None" />
        </rule>
        <rule name="ignore web forms folder 3" stopProcessing="true">
            <match url="^webformsfolder3/" />
            <action type="None" />
        </rule>
        <rule name="replacedash">
          <match url="(.*)(-)(.*)\.aspx$" />
          <action type="Redirect" url="{R:1}{R:3}" redirectType="Permanent" />
        </rule>
        <rule name="extensionless" stopProcessing="true">
              <match url="(.*)\.aspx$" />
              <action type="Redirect" url="{R:1}" redirectType="Permanent" />
        </rule>
        <rule name="removeextension" enabled="true">
            <match url=".*" negate="false" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
                </conditions>
                <action type="Rewrite" url="{R:0}" />
        </rule>
    </rules>
    
    0 讨论(0)
提交回复
热议问题