【发布时间】:2017-07-15 20:05:04
【问题描述】:
对于 firebase 文档中的代码示例,它表示要像这样启动 url 重写:
"hosting": {
// Add the "rewrites" section within "hosting"
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ]
}
当我想将参数传递给索引页面时该怎么办?我试过了:
"hosting": {
// Add the "rewrites" section within "hosting"
"rewrites": [ {
"source": "/item/**",
"destination": "/item.html?i=$1"
} ]
}
但这并没有做任何事情..
我也试过下面的答案:
"hosting": {
// Add the "rewrites" section within "hosting"
"rewrites": [ {
"source": "/item/:item",
"destination": "/item.html?i=:item"
} ]
}
但这只是返回一个 404 页面。
【问题讨论】:
-
@frank-van-puffelen - 我注意到你编辑了这个。你有解决方案吗? (还注意到您在 Firebase 工作)
-
我认为您尝试做的事情是不可能的(重写的文档没有说明变量或占位符)。相反,请查看 Cloud Functions for Firebase 将 URL 重定向到一个函数,您可以在其中编写代码来剖析路径并生成您想要的任何响应。 firebase.google.com/docs/hosting/functions
-
我真的不明白你为什么要这样做。斯蒂芬德莱尼的回答更有意义恕我直言
标签: firebase url-rewriting firebase-hosting