重定向到子页面

Redirect to sub page

我有 gitpage 结构:

pages\

------other-page-a\

-------------------index.html

------other-page-b\

-------------------index.html

------other-page-c\

------------------- ...

static\

asset-manifest.json\

favicon.ico\

index.html\

manifest.json\

service-worker.js\

主页是 React 应用程序,但 "pages" 文件夹中的某些页面不是。

我尝试使用

重定向
   <div
              className="button"
              onClick={() =>
                (window.location.replace = https://stepanvanzuriak.github.io/pages/newspaper
                )
              }
            >

但这行不通,link 更改但页面未更改

解决方案弹出并删除SWPrecacheWebpackPlugin

中的navigateFallback

您似乎正在尝试访问未从节点服务器公开的文档。由于服务器可能设置了回退(returning 相同的 index.html,无论您输入什么 url)。然后,每个请求都会 return 带有反应应用程序的主索引。将其他文件夹添加为要在节点服务器中公开的静态文件夹应该可以解决问题