我在我的应用程序中使用 URL 重写,我有两个配置文件,如下所示,第一个具有配置,第二个具有规则。但我收到 404 错误。
网页配置
  <system.webServer>
    <rewrite>
      <rewriteMaps configSource="rewritemaps.config"></rewriteMaps>
    </rewrite>
  </system.webServer>
Run Code Online (Sandbox Code Playgroud)
重写maps.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$" /> …Run Code Online (Sandbox Code Playgroud)