页面刷新返回已部署的VUEJS VUE-ROUTER APLLICATION上的404错误
该应用程序的首页/基本URL可以刷新而没有任何问题。但是其他页面返回页面刷新404。请为此做任何工作吗?
这是404的屏幕截图。 [1]: https://i.sstatic.net/lc8xd.png
The homepage/base url of the app can be refreshed with no issues. but other pages return 404 on page refresh. Please are there any work around for this?
Here is a screenshot of the 404.
[1]: https://i.sstatic.net/lc8xD.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(6)
风启觞2025-01-30 15:03:04
我找到了对我和路由器也有效的解决方案:)
IIS设置重写规则:
<rule name="MY SPA APP REWRITE RULE" stopProcessing="true">
<match url="myAppBaseURL/(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/myAppBaseURL?rewriteURL={R:1}" />
</rule>
然后在主应用程序中。
import { useRouter } from 'vue-router'
const router = useRouter()
if(new URLSearchParams(window.location.search).get('rewriteURL')){
router.push(new URLSearchParams(window.location.search).get('rewriteURL'))
}
独守阴晴ぅ圆缺2025-01-30 15:03:04
使用nginx设置服务器为VUE路由器历史模式
https://router.vuejs.org/guide/essentials/history- mode.html#nginx
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
之所以发生,是因为VUE路由仅在前端侧。因此,当您刷新页面时,它将进入后端服务器。它检查是否满足请求的任何文件。
解决这个问题。您必须告诉您的Apache Web服务器为您的前端VUE应用程序处理。
It happens because Vue routing is only on the frontend side. So when you refresh the page it goes backend server. And it checks for any files to satisfy the request.
To solve this issue. You have to tell your apache webserver to handle it for your front end Vue app.