【发布时间】:2019-09-17 15:58:37
【问题描述】:
我在我的应用程序中使用 URL 重写,我有两个配置文件,如下所示,第一个具有配置,第二个具有规则。但我收到 404 错误。
网络配置
<system.webServer>
<rewrite>
<rewriteMaps configSource="rewritemaps.config"></rewriteMaps>
</rewrite>
</system.webServer>
rewritemaps.config 文件
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="RewriteURLHometPaging" stopProcessing="true">
<match url="^Home" />
<action appendQueryString="false" type="Rewrite" url="Default.aspx" />
</rule>
<rule name="RedirectURLHomePaging" stopProcessing="true">
<match url="^Default\.aspx$" />
<action appendQueryString="false" type="Redirect" url="Home" />
</rule>
<rule name="RedirectURLContactPaging" stopProcessing="true">
<match url="^Contact-Us\.aspx$" />
<action appendQueryString="false" type="Redirect" url="Contactus" />
</rule>
<rule name="RewriteURLContactPaging" stopProcessing="true">
<match url="^Contactus" />
<action appendQueryString="false" type="Rewrite" url="Contact-Us.aspx" />
</rule>
<rule name="RedirectURLAboutPaging" stopProcessing="true">
<match url="^About-Us\.aspx$" />
<action appendQueryString="false" type="Redirect" url="About" />
</rule>
<rule name="RewriteURLAboutPaging" stopProcessing="true">
<match url="^About" />
<action appendQueryString="false" type="Rewrite" url="About-Us.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
【问题讨论】:
标签: asp.net configuration url-rewriting web-config