14

I am trying to host a website at Google Firebase. The index.html is shown as (e.x.)app.firebase.com, but when I want to access a page like login.html I need to type app.firebase.com/login.html, just app.fire-base.com/login doesn't work. How would I achieve this for every .html file in the directory (public), do I need to configure the firebase.json? I read the docs but I could not find any information.

Here is my .json

 {
      "hosting": {
        "public": "public",
        "signin": "/signin.html"

      }
    }
3
  • 1
    I'm not confident enough to give a full answer but I know that when I was deploying applications in firebase with emberjs, the routing (i.e. URLs like /login) was all handled by ember. So I think the reason you can't find anything is because it's the responsibility of your front-end framework. Commented May 25, 2017 at 6:08
  • i don't use any particular framework i followed the instuctions from getting started and i deployed through nodejs Commented May 25, 2017 at 6:10
  • So this might be a nodejs thing? Commented May 25, 2017 at 6:49

1 Answer 1

41

To omit the .html for all resource paths e.g. /login.html -> /login

  • add "cleanUrls": true to your .json.
  • firebase automatically redirects with a 301 code if user enters /login.html.

    "hosting": {
      // ...
    
      // Add the "cleanUrls" attribute within "hosting"
      "cleanUrls": true
    }
    

Read Control .html extensions to know more.


For specific routing: You can make a redirect/rewrite section in your .json as described in the following,

Sign up to request clarification or add additional context in comments.

2 Comments

Could you provide an example for login.html , do i need to do this manually for every page?
Actually this might be better. You want to remove the html for all urls right? To do it for all paths you can add "cleanUrls": true to your json firebase.google.com/docs/hosting/full-config#cleanurls This would remove the .html for all urls and automatically redirect for example /login.html to /login

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.