【发布时间】:2017-03-13 20:54:31
【问题描述】:
浏览了同一问题的几个主题。没有一个对我有用。
事情是:
我有从 create-react-app 设计的 ReactJS + Redux 应用程序。实际上它可以工作,但是当应用程序冲浪以不同于 root 的 URL 开始时会抛出 404。
安装iisnode 并尝试了网络中推荐的不同重写规则,但没有任何效果。
最后是这个:
<rule name="Redirect HTTP to HTTPS">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent"/>
</rule> -->
<rule name="Redirect non-existent paths to root">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/initialLogin/*" ignoreCase="true" negate="true" />
</conditions>
<action type="Redirect" url="/" appendQueryString="false" />
</rule>
</rules>
</rewrite>
我唯一需要的是通过根 url 发送所有传入请求,并将其余地址传递给它,以便 SPA 可以正常工作。 托管:AzureVM IIS:v10
编辑:另一个奇怪的事情是 iisnode 可以处理带有 js 文件的重定向,但是我的应用程序呈现在 index.html 中,当我试图将 index.html 指向作为处理程序时,它实际上向我显示了一个空白页。
【问题讨论】:
-
我认为我在 IISNode 上写的另一个答案会对您有所帮助,请查看here
-
感谢@peteb,部分帮助找到了解决方案
标签: node.js reactjs iis iis-10