Abhishek Choudhary
Abhishek Choudhary

Reputation: 399

Firebase: get pathname after redirect

I want to create a website which will work on any pathname, like domain.com/abc, domain.com/xyz and so on.

But I want to serve from home page only. The content will be generated dynamically.

I think it is possible using firebase.json file, but how do I do that?

I have tried redirect, but that didn't work as pathname wasn't preserved.

Upvotes: 2

Views: 61

Answers (1)

creativecreatorormaybenot
creativecreatorormaybenot

Reputation: 126594

This should be configured by default, but here you go:

"hosting": {
  // ...

  // Add the "rewrites" attribute within "hosting"
  "rewrites": [ {
    // Serves index.html for requests to files or directories that do not exist
    "source": "**",
    "destination": "/index.html"
  } ]
}

The appropriate section in the documentation can be found here.

This (rewrites) will serve content from the specified destination but not redirect to another URL.

Upvotes: 1

Related Questions