【发布时间】:2020-07-08 03:41:35
【问题描述】:
我正在尝试将我的应用程序部署到 Windows 7 PC 上的 IIS 服务器。网址是
- 我安装了 URL 重写。
- 这是我的 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="/MyApp/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我的应用程序在我的计算机上使用“ng serve”运行得非常好。当我在 Windows 7 PC 上部署 IIS 时,应用程序无法访问图像、json 文件等资源。我收到 404 错误。我认为我的 web.config 文件有问题。文件 en.json 在部署后位于 c:\inetpub\wwwroot\myapp\assets\i18n 文件夹。 请帮忙。
【问题讨论】:
-
在 IIS 中是否有默认网站映射到
c:\inetpub\wwwroot\myapp目录?请分享您如何在 IIS 中设置 Angular6 应用程序的详细信息 -
听起来你需要将
basehref 标签设置为/myappangular.io/guide/deployment#base-tag -
应用映射到c:\inetpub\wwwroot\myapp。 base_href 是“/myapp/”。
标签: angular iis url-rewriting