1

我成功删除了 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>
4

0 回答 0