2

我有两个工作区:

main
blog

使用快速入门指南,我成功地将main工作区部署到mycustomdomain.firebaseapp.com.

我的firebase.json样子如下:

{
  "firebase": "mycustomdomain",
  "public": "/",
  "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
  ],
  "rewrites": [ {
    "source": "**",
    "destination": "/index.html"
  } ]
}

请注意,当我托管 Angular 1.x 网站时,我使用重写来处理干净的 url。

现在,我想将blog工作区的内容上传到 domain mycustomdomain.firebaseapp.com/blog。我怎样才能做到这一点?

4

1 回答 1

2

单程:

"rewrites": [{
  "source": "/blog/**",
  "destination": "/blog.html"
}, {
  "source": "**",
  "destination": "/index.html"
}]

因此,路径开始的任何请求/blog/都将由 处理/blog.html,其他所有请求都将由 处理index.html

有了这个:

  • https://mycustomdomain.firebaseapp.com/->index.html
  • https://mycustomdomain.firebaseapp.com/blog/->blog.html

请注意最后一个 URL 中的斜杠。没有它,请求仍将由index.html. 如果您不希望那样,请将第一次重写更改为"source": "/blog**"

这一切都归结为Firebase Hosting 用于将路径映射到目的地的 glob 模式匹配。如果您从未对它们做过太多,请使用在线测试器与它们一起玩。我只是为此使用了http://www.globtester.com/

于 2016-01-02T15:59:31.060 回答