繁体   English   中英

将根URL调用重写为子文件夹

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM