嗨,我有一个使用sbdomain app.mywebsite.com的React网站,并且已通过以下在webconfig中的重写重定向到了一个文件夹
<rule name="appRedirect" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(app\.)(.*)$" />
</conditions>
<action type="Rewrite" url="/app/{R:1}"/>
</rule>
该应用程序可以正常工作,直到我用更新的URL刷新网站为止。
例如我可以访问app.mywebsite.com,该应用程序将带我动态访问app.mywebsite.com/mylink。问题是,当我直接访问app.mywebsite.com/mylink时,我无法访问该网站。
我尝试添加
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
一样,但是由于整个子域都被重定向了,所以它不起作用
答案 0 :(得分:0)
我通过在应用目录中添加一个webconfig文件并将404页面重写到index.html来解决了该问题
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Custom" defaultResponseMode="File" >
<remove statusCode="404" />
<remove statusCode="500" />
<error statusCode="404"
path="index.html" />
<error statusCode="500"
path="500.html" />
</httpErrors>
</system.webServer>
</configuration>