如何在托管Firebase.Json的Firebase中进行URL重写

时间:2019-11-28 17:31:33

标签: firebase firebase-hosting

在我的网站中,即在我的服务器上,我有googlee.technology/Verify/191711443.pdf,我想知道用户是否输入没有pdf扩展名的googlee.technology/Verify/191711443,我想在我的网页中显示相同的结果。怎么做。 这是我的Firebase.json文件代码:

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

1 个答案:

答案 0 :(得分:2)

要将/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"
    }

}