简体   繁体   English

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

[英]Rewrite root url call to subfolder

I have my single page app index.html located in a sub folder. 我在子文件夹中有我的单页应用程序index.html。 I would like people to see it when they acess the root url. 我希望人们在访问根URL时能看到它。 What's missing in this rewrite rule? 该重写规则缺少什么?

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

Your rule should be something like this: 您的规则应如下所示:

<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>

In your answer, you used incorrect patter in <match url= section. 在您的答案中,您在<match url=部分中使用了不正确的模式。 And for SPA you do not need to rewrite files and directories 对于SPA,您不需要重写文件和目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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