我用vite创建了一个react应用程序,现在我把它托管在本地IIS服务器上。如果我转到主页,它工作正常,所有路由都工作正常,但在转到另一个路由并试图刷新页面后,它给了我这个错误:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information:
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x8007000d
Config Error Configuration file '\\?\D:\General Store\dist\web.config' does not contain a root <configuration> tag
Config File \\?\D:\General Store\dist\web.config
Requested URL http://192.168.0.6:86/
Physical Path
Logon Method Not yet determined
Logon User Not yet determined
Config Source:
1: <rule name="ReactRouter Routes" stopProcessing="true">
2: <match url=".*" />
我该如何解决这个问题?
我尝试添加web.config
并添加了以下代码:
<code>
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<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="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
</code>
我也尝试了.htaccess
和_redirects
解决方案,但没有为我工作。
1条答案
按热度按时间ergxz8rk1#
首先,您需要确保安装:下载URL重写模块2.1:Link Here