【发布时间】:2021-06-11 10:12:14
【问题描述】:
我使用 create-react-app 和 react router 创建了一个网站。我可以从https://www.example.com/reactapp 加载网站,但是当我尝试访问像https://www.example.com/reactapp/somePage 这样的页面时出现 404 错误
网站在 8080 端口上运行,https 连接正常,在我的 package.json 中,我将主页定义为:“https://example.net/reactapp”。在我的 BrowserRouter 中,我将我的基本名称定义为“/reactapp”,并且链接可以正常工作并加载页面。
问题还在于 https://example.net/ 显示一个 wordpress 网站,当我尝试访问 https://www.example.net/reactapp/somePage 时,我从 wordpress 网站收到 404 错误。调用特定页面时如何正确获取数据?
【问题讨论】:
-
那么您需要搜索的是“推送状态路由”,您的网络服务器需要回退到 index.html 以获取您认为是前端页面的路由。
标签: reactjs url redirect react-router