IIS URL rewrite exception

*爱你&永不变心* 提交于 2019-12-25 02:18:18

问题


I have a this rewrite rule currently in place on IIS:

<rewrite>
            <rules>
                <rule name="rewrite asp">
                  <!--Removes the .asp extension for all pages.-->
                  <match url="(.*)" />
                  <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{REQUEST_FILENAME}" negate="true" pattern="(.*).asp" />
                  </conditions>
                  <action type="Rewrite" url="{R:1}.asp" />
                </rule>         
            </rules>
        </rewrite>

This enables this:

site.com/allpages --> site.com/allpages.asp

Now, is it possible to create an exception so that a particular page rewrites to another extension?

site.com/exception --> site.com/exception.php


回答1:


Create another rule, which is above the 'asp' rule with match pattern:

<match url="^exception$|(.*/)exception$" />

and action:

<action type="Rewrite" url="/{R:1}exception.php" />


来源:https://stackoverflow.com/questions/9507653/iis-url-rewrite-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!