ChinnapaReddy
ChinnapaReddy

Reputation: 89

How to do url rewriting in Firebase hosting Firebase.Json

In my website i.e in my server i have googlee.technology/Verify/191711443.pdf is there, I want to know if user enters googlee.technology/Verify/191711443 without pdf extension, I want to display same results in my web page . How to do that. This is my Firebase.json file code:

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

Upvotes: 0

Views: 336

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598668

To rewrite /Verify/191711443 to /Verify/191711443.pdf, you'd use this in your firebase.json:

"hosting": {
  // ...

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

Update: this is what the JSON from your last comment should look like:

{
    "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"
    }

}

Upvotes: 2

Related Questions