Github Pages中是否有配置允许您将所有内容重定向到index.html以获取单页应用程序? [英] Is there a configuration in Github Pages that allows you to redirect everything to index.html for a Single Page App?
问题描述
我正在尝试发布我在本地运行良好的SPA应用程序但是当我将其推送到Github Pages时,如果您直接导航到它们,则内部页面不会注册。
I'm trying to post my SPA app that works fine locally but when I push it to Github Pages, the interior pages don't register if you navigate to them directly.
例如 http://USER.github.io/PROJECT_NAME/
有效但 http://USER.github.io/PROJECT_NAME/about
不会因为没有重定向或重写。 index.html位于项目的根目录。
For example http://USER.github.io/PROJECT_NAME/
works but http://USER.github.io/PROJECT_NAME/about
doesn't because theres no redirect or rewrite. The index.html is located at the root of the project.
推荐答案
我刚刚构建了这个小包(用于bower / npm)解决那个确切的问题,所以我想我会在这里分享它作为你的问题的答案,
I just built this tiny package (for bower / npm) to solves that exact problem so I thought I'd share it here as an answer to your question,
https://github.com/websemantics/gh-pages-spa
如果你包括在 404.html
和 index.html
页面中的软件包,它会将所有流量重定向到 Index.html
,
If you include the package in your 404.html
and index.html
pages, it will redirect all the traffic to Index.html
,
它支持项目和用户/组织页面类型存储库,处理QueryStrings并附带一个工作示例,
It supports Project and User/Org Pages type repositories, handles QueryStrings and comes with a working example,
这篇关于Github Pages中是否有配置允许您将所有内容重定向到index.html以获取单页应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!