[英]Rewrite root url call to subfolder
我在子文件夾中有我的單頁應用程序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>
您的規則應如下所示:
<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,您不需要重寫文件和目錄
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.