firebase 托管 url 重写模式匹配
firebase hosting url rewrite pattern matching
如何重写网址,例如:
http://somedomain.com/page.html
到
http://somedomain.com/DIRECTORY/page.html
在 Firebase 托管中。我在 firebase.json
中尝试过,但没有成功。
"rewrites": [ {
"source": "/**.html",
"destination": "/DIRECTORY/**.html"
} ]
模式匹配如何在 firebase 托管配置中工作。帮助将不胜感激。
来自Firebase Hosting documentation on rewrites:
The rewrites attribute contains an array of rewrite rules, where each rule must include:
A source
specifying a glob pattern
A destination
, which is a local file that must exist
所以看起来您只能重写到特定的现有文件,而不能重写到另一个通配符。
您可以考虑改用重定向,因为 do 支持 dynamic segments in their destination URL.
"redirects": [ {
"source": "/:page*",
"destination": "http://somedomain.com/DIRECTORY/:page",
"type": 301
}]
这会将重定向指令发送回客户端,以便他们能够看到最终路径是什么。
如何重写网址,例如:
http://somedomain.com/page.html
到
http://somedomain.com/DIRECTORY/page.html
在 Firebase 托管中。我在 firebase.json
中尝试过,但没有成功。
"rewrites": [ {
"source": "/**.html",
"destination": "/DIRECTORY/**.html"
} ]
模式匹配如何在 firebase 托管配置中工作。帮助将不胜感激。
来自Firebase Hosting documentation on rewrites:
The rewrites attribute contains an array of rewrite rules, where each rule must include:
A
source
specifying a glob patternA
destination
, which is a local file that must exist
所以看起来您只能重写到特定的现有文件,而不能重写到另一个通配符。
您可以考虑改用重定向,因为 do 支持 dynamic segments in their destination URL.
"redirects": [ {
"source": "/:page*",
"destination": "http://somedomain.com/DIRECTORY/:page",
"type": 301
}]
这会将重定向指令发送回客户端,以便他们能够看到最终路径是什么。