Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do we really need URL Rewrite module for hosting angular app on IIS?

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>
like image 902
sandy Avatar asked Sep 11 '25 13:09

sandy


1 Answers

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)

like image 57
Andrei Avatar answered Sep 14 '25 03:09

Andrei