我正在使用Angular 5.2并在我的本地IIS服务器上部署,一切都运行良好。
我的本地URL看起来像这样:- http://localhost/DEV
DEV是我本地IIS服务器中的虚拟目录。上面的URL一切正常。
现在我想在DEV下添加另一个嵌套的子VD作为childApp。
我希望我的应用程序以http://localhost/DEV/childApp的方式工作。
所以我更改了index.html内容,加入了base href:
<base href="/DEV/childApp/">
并且我已经更新了web.config文件,使URL重写规则为:
从
<action type="Rewrite" url="./index.html" />
TO
<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 Rewrite模块错误。无法添加具有唯一密钥属性“名称”设置为“Angular Routes”的类型“规则”的重复集合条目
请建议如何修复web.config中的URL重写或其他位置。
<clear />
? - Daniel W Strimpel