在iis上部署 AngularJS

本文详细介绍如何将Angular应用程序部署到IIS上,包括下载安装URL Rewrite模块、使用Angular CLI进行打包、配置web.config文件等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.下载Microsoft URL Rewrite Module 2.0 for IIS (x64) https://www.microsoft.com/en-us/download/details.aspx?id=47337

2.无脑安装

3.安装angular-cli

npm install -g @angular-cli

如果打包报错,可以考虑重装一下

npm uninstall -g angular-cli @angular/cli
npm cache clean
npm install -g @angular/cli

 

4.打包angular

ng build --prod --aot

5.把打包生成的dist文件夹内容拷贝到iis的网站目录下

6.在目录下新建一个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>

 

7.运行网站

转载于:https://www.cnblogs.com/freebird911/p/9404166.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值