Angular 5 : 将应用程序部署到嵌套文件夹下的 IIS
Angular 5 : Deploy app to IIS under nested folder
我正在使用 Angular 5.2 并部署在我的 localhost IIS 服务器 中,它工作正常。
我的本地主机 URL 看起来像这样:- http://localhost/DEV
DEV 是我的本地 IIS 服务器中的虚拟目录。以上 URL 一切正常。
现在我想在 DEV 中添加另一个嵌套的 VD 作为 childApp。
我希望我的应用程序以 http://localhost/DEV/childApp 的形式运行。
所以我将 index.html 内容更改为具有这样的基本 href :-
<base href="/DEV/childApp/">
并且还将 web.config 文件的 URL 重写规则更新为:-
来自
<action type="Rewrite" url="./index.html" />
到
<action type="Rewrite" url="/DEV/childApp/" />
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="/DEV/childApp/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
但它向我抛出错误:-
HTTP 错误 500.52 - URL 重写模块错误。无法添加唯一键属性 'name' 设置为 'Angular Routes'
类型 'rule' 的重复集合条目
请建议如何为 URL 重写或其他地方修复 web.config。
将 <clear />
添加到 web.config 是解决方案。
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear /> <!--Imperative Step, otherwise IIS will throw err-->
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
............
..........
我正在使用 Angular 5.2 并部署在我的 localhost IIS 服务器 中,它工作正常。
我的本地主机 URL 看起来像这样:- http://localhost/DEV
DEV 是我的本地 IIS 服务器中的虚拟目录。以上 URL 一切正常。
现在我想在 DEV 中添加另一个嵌套的 VD 作为 childApp。 我希望我的应用程序以 http://localhost/DEV/childApp 的形式运行。
所以我将 index.html 内容更改为具有这样的基本 href :-
<base href="/DEV/childApp/">
并且还将 web.config 文件的 URL 重写规则更新为:-
来自
<action type="Rewrite" url="./index.html" />
到
<action type="Rewrite" url="/DEV/childApp/" />
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="/DEV/childApp/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
但它向我抛出错误:-
HTTP 错误 500.52 - URL 重写模块错误。无法添加唯一键属性 'name' 设置为 'Angular Routes'
类型 'rule' 的重复集合条目请建议如何为 URL 重写或其他地方修复 web.config。
将 <clear />
添加到 web.config 是解决方案。
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear /> <!--Imperative Step, otherwise IIS will throw err-->
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
............
..........