IIS Express网址重写模块非常简单的重定向不起作用

And*_*rew 2 iis asp.net-mvc web-config iis-express url-rewrite-module

我想重定向index.phphome在这个片段。

  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Redirect index.php to home" stopProcessing="true">
          <match url="index.php" ignoreCase="false" />
          <action type="Redirect" url="home" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>      
  </system.webServer>
Run Code Online (Sandbox Code Playgroud)

我正在运行IIS Express 8.5。对于http://localhost/index.php,没有重定向发生,我得到的是index.php和相同的旧404。试图删除浏览器缓存没有帮助。任何的想法?

我无需执行任何操作即可启用Url-Rewrite-Module,对吗?

And*_*rew 5

好的,我终于找到了问题。我的ASP.NET MVC 5项目有两个Web.config:

  • /Web.config
  • /Views/Web.config

/Views/Web.config错误地把上面的代码片段放在了上面,但是没有用。现在,我将其移至/Web.config,并且效果很好。