Web配置重定向到.aspx版本,而不是干净版本



wwwhttp重定向到https://example.com/*的代码

<rule name="NonWwwRedirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.example.com$" />
</conditions>
<action type="Redirect" url="https://example.com/{R:1}" />
</rule>

这有点奏效。例如,问题是重定向总是转到https://example.com/hello.aspx而不是https://example.com/hello

我用它来让非aspx URL工作,它们确实这样做了,只是重定向选择转到.aspx版本。

<rule name="RewriteASPX">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.aspx" />
</rule>

有人知道问题是什么吗?

EDIT:任何非aspx URL都会重定向到.aspx版本。

有关如何删除.aspx扩展的详细信息,请参阅前面的回答

有关https和www重写的信息,请参阅elmah的博客文章

最新更新