【问题标题】:How to change my url from https://example.com/name.html to https://example.com/name?如何将我的网址从 https://example.com/name.html 更改为 https://example.com/name?
【发布时间】:2023-03-21 21:10:01
【问题描述】:

如何将我的网址从https://example.com/name.html 更改为https://example.com/name? 我正在使用 Firebase 托管来托管我的网站。该网站是使用 bootstrap studio 以 HTML 和 javascript 制作的。

在线阅读各种解决方案后,我知道“.htaccess”文件可用于更改 url,但没有一个解决方案提供使用 Firebase 托管的方法。

【问题讨论】:

  • “更改您的网址”是什么意思?如果您只是希望/name.html 中的文件也出现在/name 中,您可以使用rewrites

标签: html firebase firebase-hosting


【解决方案1】:

Firebase 托管有一个名为 cleanUrls 的设置,用于控制 HTML 扩展程序的存在/不存在。请参阅controlling .html extensions 上的文档:

cleanUrls 属性允许您控制 URL 是否应包含 .html 扩展名。

如果为 true,Hosting 会自动从上传的文件 URL 中删除 .html 扩展名。如果在请求中添加了.html 扩展,Hosting 会执行301 重定向到同一路径,但会消除.html 扩展。

通过在您的 firebase.json 文件中的主机内包含 cleanUrls 属性来指定包含 .html 扩展。例如:

"hosting": {
   // ...

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-16
    • 2016-04-29
    • 2020-09-24
    • 2014-03-04
    • 1970-01-01
    • 2016-10-04
    • 2019-05-18
    相关资源
    最近更新 更多