【发布时间】:2017-09-19 23:23:11
【问题描述】:
我有一个使用 asp.net 和 wordpress 的网站。 wordpress 组件位于名为 wordpress 的子目录中。它使用永久链接。
我还有一个 asp.net 站点,它使用站点根目录作为 ist 顶级目录。
asp.net 站点使用了一些重写规则,因此我可以在没有 .aspx 扩展名的情况下访问 .aspx 页面。它实际上将 .aspx 添加到页面。这是web.config文件中的重写规则
<rewrite>
<rules>
<rule name="san aspx">
<!--Removes the .aspx 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}" pattern="/*.png" negate="true" />
<add input="{REQUEST_FILENAME}" pattern="/*.php" negate="true" />
<add input="{REQUEST_FILENAME}" pattern="/wordpress/*.php" negate="true" />
<add input="{REQUEST_FILENAME}" pattern="/webservice/*.asmx" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.aspx" />
</rule>
</rules>
</rewrite>
这适用于 asp.net 页面。
但是,它也将 .aspx 扩展名添加到 wordpress 页面。因此,如果我有一个页面(显示为永久链接),例如
/recurring-billing/
它会寻找一个名为
的页面/recurring-billing/.aspx
如果我关闭永久链接,wordpress 页面会正确显示,因为 asp.net 重写规则
<add input="{REQUEST_FILENAME}" pattern="/*.php" negate="true" />
正确识别.php页面并忽略重写。
问题:我在 asp.net 重写规则中需要什么额外条件,这样它就不会将 .aspx 添加到 wordpress 永久链接中。
【问题讨论】:
标签: asp.net wordpress url-rewriting