2

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?

Andrew
  • 817
  • 2
  • 10
  • 21
  • Use the IIS manager to create and test your redirect rules and check your access log file to see which URLs are generating 404 errors. – Tim3880 May 19 '15 at 22:42
  • @Tim3880 this is IIS Express, IIS manager is only for the main IIS no? Wouldn't IIS manager also just generate rules like mine in the config file? I do not need to check which URLs are generating 404, this is a single URL that I'm trying to redirect, that's the one I'm testing and only getting 404 because the redirect is not working. – Andrew May 19 '15 at 23:00
  • Some clarification - are you trying to redirect from `localhost/index.php` to `localhost/home` (and not just rewrite the URL)? – Brendan Green May 19 '15 at 23:16
  • Can you check your website binding? sometime IIS does not like localhost. If not there, add localhost to your domain list – Tim3880 May 19 '15 at 23:21
  • @Tim3880 he is using IISExpress, not IIS – Brendan Green May 19 '15 at 23:21
  • Shouldn't your redirect URL be `localhost/home` then, and not just `home`? – Brendan Green May 19 '15 at 23:22
  • @BrendanGreen tested it, didn't help. – Andrew May 19 '15 at 23:27
  • And browsing to `localhost/home` works? – Brendan Green May 19 '15 at 23:32

1 Answers1

5

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.

Andrew
  • 817
  • 2
  • 10
  • 21