我们真的需要 URL 重写模块来在 IIS 上托管 angular 应用程序吗?

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

对我们来说 angular 应用程序在 IIS 上没有安装 URL 重写模块的情况下工作。我们是否需要 URL 重写模块以在 IIS 上托管 angular 应用程序?如果我们不安装它会有什么不同?

适用于以下 web.config..我刚刚评论了重写部分并添加了
默认文档

<?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主要用于编写SPA。因此,您可能会有“/home”、“/products”和其他应该 运行 相同 angular 应用程序但您的应用程序将呈现不同内容的 url。因此,当用户导航到 'yoursite.com/home' 时,它应该会看到 Angular 应用主页。并且没有重写你只会看到 404 (因为没有 /home.html 在于来源)