And*_*ing 7 http-status-code-404 firebase firebase-hosting
我刚刚开始在 firebase 上托管一个 Web 应用程序。firebase cli使用(firebase-tools)的自动设置404.html在我的公共文件夹中创建了一个文件。
但我不想看到自定义 404 错误页面,也不想看到 Firebase 的默认错误页面。我想将所有 404 重定向到起始页,以便应用程序无论如何都会被初始化。(我的本地设置webpack-dev-server工作正常)
解决方法是将相同的内容index.html放入404.html. 但这会导致双倍的维护。
我在这里找到了一些有关重定向配置的信息https://firebase.google.com/docs/hosting/url-redirects-rewrites。但 404 错误类型的重定向是不可能的。使用.htaccess文件是不可能的。
我是否缺少更改此行为的正确位置,无论是在我的firebase.json文件中还是在https://console.firebase.google.com/中?
不确定这是否适合你,我从来没有用过.htaccess,但就我而言,我总是这样修复它:
您可以将通配符路由作为文件重写部分中的最后一个路由firebase.json,以便任何以前未声明的路由都将匹配:
"rewrites": [
{
// route info here
},
{
// another route
},
{
// If it makes it here, it didn't match any previous routing
// Match all routes that get to this point and send them to the home page.
"source": "**",
"destination": "/index.html"
}
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3672 次 |
| 最近记录: |