Firebase托管URL需要.html才能显示页面 [英] Firebase hosting URL needs .html to display a page
问题描述
我正在尝试在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
.
如果用户输入 -
firebase会自动使用
301
代码进行重定向.
/login.html
,- 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屋!