[英]Angular 5 : Deploy app to IIS under nested folder
我正在使用Angular 5.2並部署在我的localhost IIS服務器上 ,它運行正常。
我的localhost URL如下所示: - http:// localhost / DEV
DEV是我的localhost 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”
請建議如何修復web.config以進行URL重寫或其他地方。
將<clear />
添加到web.config是解決方案。
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear /> <!--Imperative Step, otherwise IIS will throw err-->
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
............
..........
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.