本文转自:https://www.cnblogs.com/kingkangstudy/p/7699710.html
Angular项目部署到一个IIS服务器上
1.安装URL rewrite组件:
网址:https://www.microsoft.com/en-us/download/details.aspx?id=47337
2.将angular项目打包生成项目ng build,将生成的dist文件夹下的内容拷贝到网站的目录下
3.在该网站目录下添加一个配置文件web.config,复制下边的内容到web.config
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="AngularJS" 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>
4.按照正常的项目部署方式,部署项目后启动