简体   繁体   中英

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>

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)

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