Search code examples
javascriptfirebasefirebase-hosting

Redirect only the root URL to some other file in Firebase


I am using firebase hosting for my web application.

I want to show lp.html at the root of my URL and index.html at everywhere else. To achieve this, I have configured my firebase.json like this:

{
  "hosting": {
    "public": "build/es6-bundled",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/",
        "destination": "/lp.html"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

But when I user firebase serve and open http://localhost:5000/, I see the contents from index.html. How can I have the root URL point to lp.html?


Solution

  • Turns out for some reason, firebase picks to serve index.html at the root URL by default without consulting the firebase.json. To avoid this, I changed the name of my index.html file to app.html, and everything worked as expected.