reactjs - reactJs项目如何直接访问路由
问题描述
我正在开发一个 reactJS 应用程序,我需要让用户能够直接访问它的路由。但是我什么时候得到404。
<Router>
<>
<Route exact path="/" component={App} />
<Route path="/video" component={YoutubeVideoScreen} />
</>
</Router>
当我尝试访问“www.hostname.com/video”时,它给了我一个 404 错误。我认为问题在于与单页应用程序相关的 apache 配置。以前,我在将类似的应用程序上传到 firebase 托管时遇到了同样的问题,但我通过在 firebase.json 中添加类似下面的内容解决了这个问题。
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
那么,如何在 apache 服务器中实现这一点呢?
解决方案
推荐阅读
- kotlin - 无法从同一网络上的不同设备访问 Micronaut
- http - 如何将 txt 文件上传到 Heroku,然后通过其 URL 路径访问它
- r - 在 Mac 上的 r 4.0.3 中安装包 mxnet 时出错
- javascript - 在单击事件中更改 div 的背景颜色会产生意外(或预期?)结果
- docker - Azure Dev Ops:构建 .NET 作为发行版
- java - MySQL Java 准备好的语句语法错误
- javascript - window.np 是未定义的,即使它在打印窗口时出现在控制台中
- r - 在 R 中使用Integrate() 进行集成
- javascript - 获取数组中单个对象的索引或值
- mongodb - 遍历 MongoDB 中的列表