如何 url 在 Firebase 托管中重写 Firebase.Json

How to do url rewriting in Firebase hosting Firebase.Json

在我的网站中,即在我的服务器中,我 googlee.technology/Verify/191711443.pdf is there, I want to know if user enters googlee.technology/Verify/191711443 没有 pdf 扩展名,我想在我的网页中显示相同的结果。怎么做。 这是我的 Firebase.json 文件代码:

{ 
  "hosting": {
    "site": "chinnapareddy",
    "public": "y",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  },
  `"functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint"
    ],
    "source": "functions"`
  }
}

要将 /Verify/191711443 重写为 /Verify/191711443.pdf,您需要在 firebase.json:

中使用它
"hosting": {
  // ...

  // Add the "rewrites" attribute within "hosting"
  "rewrites": [ {
    "source": "/Verify/191711443",
    "destination": "/Verify/191711443.pdf"
  }]
}

更新:这是您上一条评论 中的 JSON 应该 的样子:

{
    "hosting": {
        "site": "chinnapareddy",
        "public": "y",
        "ignore": ["firebase.json", "/.*", "**/node_modules/"]

        "rewrites": [{
            "source": "/Verify/191711443",
            "destination": "/Verify/191711443.pdf"
        }]

    },

    "functions": {
        "predeploy": ["npm --prefix \"$RESOURCE_DIR\" run lint"],
        "source": "functions"
    }

}