【问题标题】:IIS URL rewrite exceptionIIS URL 重写异常
【发布时间】:2012-02-29 22:28:01
【问题描述】:

我目前在 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 --> site.com/allpages.asp

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

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

【问题讨论】:

    标签: iis-7 url-rewriting


    【解决方案1】:

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

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

    和行动:

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

    【讨论】:

      猜你喜欢
      • 2016-07-30
      • 2013-07-01
      • 2013-08-05
      • 2016-06-27
      • 2013-06-16
      相关资源
      最近更新 更多