在生成的dist目錄下 新增web.config文件
內容如下:
<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="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
IIS需要安裝URL ReWrite模塊
下載地址:https://www.iis.net/downloads/microsoft/url-rewrite
安裝成功後,IIS首頁顯示如下圖,重啓對應網站即可