IIS站点下,React重新刷新,404问题的解决

问题原因:

React Router是客户端的路由,当再次刷新时,IIS无法定位,因此抛出404错误。

解决方法:

配置站点下的web.config文件。

<rewrite>
<rules>
<rule name="Rewrite Text Requests" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_METHOD}" pattern="^GET$" />
<add input="{HTTP_ACCEPT}" pattern="^text/html" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/WechatApp/index.html" />
</rule>
</rules>
</rewrite>

配置web.config的前提,需要服务器安装了重定向组件,组件的下载位置:

re_write_x86_zh_CN.msi from microsoft

re_write_x64_zh_CN.msi from microsoft

NOI-001—《C++编程及竞赛训练》 NOI-002—《普及组竞赛强化训练课程》 NOI-003—《初级算法课程》
原文地址:https://www.cnblogs.com/fphuang/p/6697860.html