【发布时间】:2019-10-03 00:29:32
【问题描述】:
好的,这与其他问题类似,但我不熟悉 url rewrite。
我在 IIS 下托管(希望仅用于开发和测试)一个 React 应用程序。
如果托管在站点文件夹的根目录中,则一切正常
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Static Assets" stopProcessing="true">
<match url="([\S]+[.](svg|js|css|png|gif|jpg|jpeg))" />
<action type="Rewrite" url="{R:1}" />
</rule>
<rule name="ReactRouter Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
但我需要它在子应用程序中工作。例如:http://myserver:8888/myapp。其中 myapp 是子应用程序。
IIS 图:
网站 - 我的网站 - 我的应用程序
包含路由的 url 的更好示例:http://myserver:8888/myapp/1234/abcd。 1234 和 abcd 是路由值/参数。
contents of my app directory are:
index.html
main.a9e1df0325f4fdb57e7e.js
vendors~main.c8848853e10f698af19d.js
web.config
谢谢
吉娜
【问题讨论】:
标签: iis url-rewriting react-router