我有两个工作区:
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
。我该如何实现?
单程:
"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用于将路径映射到目标的全局模式匹配。如果您从来没有对它们做过太多的事情,请使用在线测试仪与他们一起玩。我只是为此使用http://www.globtester.com/。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句