我将如何使Vue路由器与GitHub页面一起使用?
我刚刚使用github页面将我的VUE应用程序部署到了我的网站。
该网站成功托管在 https://astroorbis.com 。
这是问题;当您单击页面顶部的“链接”按钮时,它将您成功地将您纳入 https://astroorbis.com/链接,但是当您尝试访问URL本身时(输入 https://astroorbis.com/links )进入您的浏览器,它返回404。
还有其他具有相同错误的链接,例如/discord,/github等。
我在
解决方案是什么?
I just deployed my Vue app to my website using GitHub Pages.
The website is successfully hosted at https://astroorbis.com.
Here's the problem; When you click the "links" button at the top of the page, it successfully nagivates you to https://astroorbis.com/links, but when you try visiting the URL itself (typing in https://astroorbis.com/links) into your browser, it returns a 404.
There are other links that have the same error, such as /discord, /github, etc.
I tried the solution at Vue Router, GitHub Pages, and Custom Domain Not Working With Routed Links, but it failed as well.
What would be the solution for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如此部分的HTML5模式
因此,解决方案将是使用喜欢
在Netlify上,您还需要添加以下内容才能工作
/public/_redirects
,所以我不确定github页面,但是您应该在那里有类似的东西,某种方法可以捕捉所有路线并将其发送到
index.html
您的初始水疗页面加载。否则,也许只是尝试使用
_redirects
配置进行Netlify。也许 /a>在GitHub页面上可能会有所帮助。
您给定链接中的黑客似乎是唯一可行的解决方案,但对SEO仍然不利,所以,是的,取决于您是否想要(我想)。
在这种情况下,如果您想拥有一些静态生成的页面(有关SEO的最佳方法),则可以尝试NUXT.JS,网格或Vitesse。
As stated in this section of the HTML5 mode
So, the solution would be to use something like that
On Netlify, you also need to add the following for it to work
/public/_redirects
So I'm not sure about Github Pages but you should have something similar there, some way of catching all routes and sending them to the
index.html
of your initial SPA page load.Otherwise maybe just give a try to Netlify with the
_redirects
configuration.Maybe this article could help regarding Github pages.
The hack in your given link seems to be the only viable solution but it's still bad for SEO so yeah, depends if you want any (I guess so).
In that case, you could try Nuxt.js, Gridsome or Vitesse if you want to have some statically generated pages (best approach regarding SEO).