简体   繁体   中英

IIS Express Url Rewrite Module very simple redirect not working

I want to redirect index.php to home in this snippet.

  <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>

I have IIS Express 8.5 running. No redirect is happening for http://localhost/index.php , I get index.php and the same old 404. Tried deleting browser cache, didn't help. Any idea?

I don't have to do anything to enable the Url-Rewrite-Module, do I?

Ok I finally found the problem. My ASP.NET MVC 5 project had two Web.configs:

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

I had put the snippet above in /Views/Web.config by mistake, and it didn't work. Now I moved it to /Web.config , and it works perfectly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM