我的单页应用index.html位于子文件夹中。我希望人们在访问根网址时看到它。这个重写规则中缺少什么?
<rewrite>
<rules>
<rule name="SPA rewrite">
<match url="http://app.local" />
<action type="Rewrite" url="http://app.local/SPA/dist" />
</rule>
</rules>
</rewrite>
答案 0 :(得分: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,您不需要重写文件和目录