【发布时间】:2018-08-06 11:32:21
【问题描述】:
我正在使用 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/">
并且还将 URL 重写规则的 web.config 文件更新为:-
来自
<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 重写模块错误。无法添加类型为“规则”且唯一键属性“名称”设置为“角度路线”的重复集合条目
请建议如何修复 web.config 以进行 URL 重写或其他地方。
【问题讨论】:
-
这是不同的,它与 Angular 应用程序及其基础 href 有关。
-
如果这是您遇到的错误,则不会。这不是 Angular 错误,而是 IIS 错误。您是否添加了
<clear />作为答案? -
感谢 Daniel W Strimpel
标签: angular iis url-rewriting angular5 angular-routing