我有一个公用文件夹,如:
/public
index.html
/landing
index.html
/membership
index.html
/public/index.html是一个spa,所以对/**的每个请求都应该重写为/index.html
登陆/和/或成员资格/是两个静态HTML登陆,所以每个请求不应该被重写。
google支持建议使用firebase.json:
{
"functions": {
"source": "functions"
},
"hosting": {
"public": "public",
"redirects": [{
"source": "/landing",
"destination": "index.html"
},
{
"source": "/membership",
"destination": "index.html"
}
],
"rewrites": [{
"source": "/membership/**",
"destination": "/membership/index.html"
}
],
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
所有内容都被重定向到/index.html…
甚至尝试过:
{
"functions": {
"source": "functions"
},
"hosting": {
"public": "public",
"redirects": [{
"source": "/landing/**",
"destination": "/landing/index.html"
},
{
"source": "/membership/**",
"destination": "/membership/index.html"
}
],
"rewrites": [{
"source": "**",
"destination": "/index.html"
}
],
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
同样的结果,一切都会/