4

For us angular app is working without URL rewrite module installed on IIS. Do we need URL rewrite module to host angular app on IIS? What difference it will make if we don't install that?

It works with below web.config..I just commented rewrite part and added
default document

<?xml version="1.0" encoding="utf-8"?>
<configuration>

<system.webServer>
  <!-- <rewrite>
    <rules>
      <rule name="Angular Routes" stopProcessing="true">
        <match url=".*" />
        <conditions logicalGrouping="MatchAll">
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="/SCOAP/index.html" />
      </rule>
    </rules>
  </rewrite> -->
  <defaultDocument enabled="true">
         <files>
            <add value="index.html" />
         </files>
  </defaultDocument>
</system.webServer>

</configuration>
sandy
  • 438
  • 4
  • 8

1 Answers1

7

Angular is mostly used for writing SPAs. So you will probably have '/home', '/products' and other urls that should run the same angular application but just different content will be rendered by your app. So when user navigates to 'yoursite.com/home' it should see Angular app home page. and witout rewrites you will see just 404 (because no /home.html lies in sources)

Andrei
  • 10,117
  • 13
  • 21
  • I have different urls like '/agreement/list', '/dashboard' and I am not getting any 404. – sandy Jul 02 '19 at 18:39
  • 3
    does it work ok when you refresh the browser on those pages ? – Andrei Jul 02 '19 at 18:44
  • 2
    ahh...it does not so basically we need to install and use URL rewrite module on IIS. Thank you so much for help. – sandy Jul 02 '19 at 18:46
  • Can anyone look in to this? https://stackoverflow.com/questions/59872738/angular-application-not-loading-with-parameters-when-reloading-with-iis-url-rewr – Phoenix Jan 23 '20 at 09:41