2017-07-25 48 views
0

我的單頁應用程序index.html位於子文件夾中。我希望人們在訪問根網址時看到它。這個重寫規則中缺少的是什麼?將子URL調用重寫到子文件夾

<rewrite> 
    <rules> 
    <rule name="SPA rewrite"> 
     <match url="http://app.local" /> 
     <action type="Rewrite" url="http://app.local/SPA/dist" /> 
    </rule> 
    </rules> 
</rewrite> 
+0

您是否在同一個應用程序中有其他內容或資源。您可以添加其他內容嗎?例如,你是否有一些動態的內容api /產品/東西等也從應用程序提供或它只是靜態網站?根據條件規定,我們可以制定規則,而不會影響網站中的任何其他內容(動態和靜態)。 –

回答

0

你的規則應該是這樣的:

<rule name="SPA rewrite" stopProcessing="true"> 
    <match url=".*" /> 
    <conditions logicalGrouping="MatchAll"> 
     <add input="{HTTP_HOST}" pattern="app.local" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="/SPA/dist" /> 
</rule> 

在你的答案,你在<match url=節中使用不正確行話。對於SPA,您不需要重寫文件和目錄

相關問題