ASP.NET删除目录所在的aspx扩展

时间:2013-09-03 13:48:31

标签: asp.net iis url-rewriting web-config

我成功删除了aspx扩展,但如果目录存在与aspx文件同名,则仍然存在问题。示例:domain.com/contact-us.aspx存在,domain.com/contact-us/(文件夹)也存在。这样我的重写规则强制到不允许列出目录的目录(但我想要aspx文件!)。

我在web.config中使用的内容:

<rule name="RemoveASPX" enabled="true" stopProcessing="true">
    <match url="(.*)\.aspx" />
    <action type="Redirect" url="{R:1}" />
</rule>
<rule name="AddASPX" 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}.aspx" />
</rule>

0 个答案:

没有答案
相关问题