Firebase托管URL需要.html才能显示页面 [英] Firebase hosting URL needs .html to display a page

查看:78
本文介绍了Firebase托管URL需要.html才能显示页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Google Firebase上托管一个网站. index.html显示为(e.x.)app.firebase.com,但是当我要访问诸如login.html之类的页面时,我需要键入app.firebase.com/login.html,只是app.fire-base.com/login不起作用. 如何为目录(公共)中的每个.html文件实现此目标,我是否需要配置firebase.json?我阅读了文档,但找不到任何信息.

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.

这是我的.json

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

      }
    }

推荐答案

为所有资源路径省略.html,例如/login.html -> /login

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

  • "cleanUrls": true添加到您的.json.
  • 如果用户输入/login.html
  • firebase会自动使用301代码进行重定向.

  • 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
}

阅读控制.html扩展以了解更多信息.

Read Control .html extensions to know more.

对于特定的路由: 您可以按照以下说明在.json中创建重定向/重写部分,

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

  • Configure redirects
  • Configure rewrites

这篇关于Firebase托管URL需要.html才能显示页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆