我正在嘗試創建一個 Firebase 路由規則,它將特定子目錄下的任何請求重新路由到服務器上的一個特定檔案。
如果我有一個正常的檔案路徑(帶有擴展名),這可以作業,但如果我從初始請求中洗掉了擴展名,這似乎不起作用。
有誰知道這種“重寫”邏輯是如何作業的,有沒有辦法以這種方式利用?
(或者我只是做錯了,因為我不清楚為什么第一條規則也不起作用)
使用此規則集:
"rewrites": [
{
"source": "/access-token/somefolder/else.html",
"destination": "/access-token/2.json"
},
{
"regex": "^/access-token/[\\d] $",
"destination": "/access-token/2.json"
},
{
"regex": "^/access-token/[\\d] \\.json$",
"destination": "/access-token/1.json"
},
{
"source": "**",
"destination": "/index.html"
}
]
測驗結果:
request : https://[root]//access-token/somefolder/else.html <-- this path does not exist, i was only using this as a test
expected: routes to 'destination'
actual : routes to root (probably hitting final rule?)
request : https://[root]/access-token/12
expected: routes to 'destination'
actual : routes to "404 not found"
request : https://[root]/access-token/12.json
expected: routes to 'destination'
actual : re-routes as intended
uj5u.com熱心網友回復:
對于第一個問題,由于重定向比重寫具有更高的優先級,因此可能在.html它到達重寫引擎時已經從傳入的 URL 中剝離。
{
"source": "/access-token/somefolder/else",
"destination": "/access-token/2.json"
}
對于以下專案,請不要轉義\角色,也不需要 IIRC 的錨點。
{
"regex": "/access-token/\d ",
"destination": "/access-token/2.json"
}
{
"regex": "/access-token/\d \.json",
"destination": "/access-token/1.json"
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/507504.html
標籤:Google Cloud Collective 火力基地 firebase 托管 重新路由
上一篇:使用云功能安排日常會議
