Firebase hosting URL needs .html to display a page

。_饼干妹妹 提交于 2020-07-06 10:34:06

问题


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"

      }
    }

回答1:


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,

  • Configure redirects
  • Configure rewrites


来源:https://stackoverflow.com/questions/44173400/firebase-hosting-url-needs-html-to-display-a-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!