IIS URL重写异常

时间:2012-02-29 22:28:01

标签: iis-7 url-rewriting

我目前在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>

这样可以实现:

site.com/allpages - &gt; site.com/allpages.asp

现在,是否可以创建一个例外,以便特定页面重写到另一个扩展名?

site.com/exception - &gt; site.com/exception.php

1 个答案:

答案 0 :(得分:0)

创建另一条规则,该规则位于带有匹配模式的“asp”规则之上:

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

和行动:

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