Firebase Hosting – 无法将默认流量重写为索引以外的任何其他流量.html



我有几个firebase托管的站点指向同一目录。

对于这个特定的例子,我希望特定的网站使用不同于公共文件夹的index.html文件的默认索引。

我已经将子站点firebase主机部署设置为类似于以下内容:

{
"target": "subsite",
"public": "hosting/public_mysite",
"headers": [
{
"source": "/",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache, no-store, must-revalidate"
}
]
}
],
"ignore": [
"firebase.json",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/about",
"destination": "/subsite/about.html"
},
{
"source": "/reviews",
"destination": "/subsite/reviews.html"
},
{
"source": "**",
"destination": "/subsite/home.html"
}
]
}

在子网站上,urls/about和/reviews确实加载了重写部分中列出的请求的替代页面。

最后一条规则"source": "**"似乎被完全忽略了,firebase无论如何都会加载/index.html。

为什么不加载/subsite/home.html

文件肯定和其他文件在一起。

请参阅主机响应的优先级顺序。

  1. /__/*路径段开头的保留命名空间
  2. 配置的重定向
  3. 完全匹配静态内容
  4. 配置的重写
  5. 自定义404页面
  6. 默认404页

访问/将在与任何rewrites匹配之前优先考虑根index.html。如果你想呈现一个不同的资源,你必须在没有根index.html.的情况下部署

最新更新