【问题标题】:How to hide unneccessary subfolders in website address in firebase如何在firebase的网站地址中隐藏不必要的子文件夹
【发布时间】:2020-06-03 19:00:15
【问题描述】:

我想减少我在 firebase 中网页的 URL 长度。 html 文件位于公共文件夹内的 html 文件夹中。现在索引页的 URL 是:www.lstein-28b62.web.app/htmlfolder/index.html 是否可以将其更改为 www.lstein-28b62.web.app/index.html 而无需将 index.html 文件从 htmlfolder 子文件夹中取出? 我基本上只是想隐藏 /htmlfolder/ 子文件夹。它应该类似于 js 函数 window.history.pushState(),尽管如果页面被刷新,这会产生问题。

【问题讨论】:

标签: html firebase url firebase-hosting


【解决方案1】:

你有两个选择:

  1. folder you deploy 更改为public/html,以便只部署HTML 文件夹的内容。

    "hosting": {
      "public": "public"
    
      // ...
    }
    
  2. 使用rewrite rule 从根目录提供内容。

    "hosting": {
      // ...
    
      // Add the "rewrites" attribute within "hosting"
      "rewrites": [ {
        "source": "/html/index.html",
        "destination": "/index.html"
      } ]
    }
    

我强烈推荐第一种方法,因为后者需要更多的维护。

【讨论】:

  • 感谢您的帮助。不幸的是,这不是我想要的。第一种方法对我不起作用,因为我的公用文件夹中有多个文件夹,应该全部部署。第二种方法是对我存储在子文件夹中的所有资源(例如 js、css、图像)产生问题。如果可以留在实际页面上并且网址会以不同方式显示,那就太好了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-29
相关资源
最近更新 更多