about.html编辑:修复了我在 HTML 中提到的错误/about/,但我仍然遇到相同的问题。
我知道这是一个以前多次被问过的问题的重复,但其他人的解决方案对我不起作用。我想做的是重新路由,例如,index.html到/index/和about.html到/about/。
我尝试使用@louisvno的答案here、@michael-bleigh的答案here和@HarsH的答案here,所有这些都是将以下内容添加到.json文件中:
"hosting": {
"cleanUrls": true
}
Run Code Online (Sandbox Code Playgroud)
(这也是 Firebase配置托管行为指南的“控制 .html 扩展”部分的答案。 )
然而,这没有效果。在我的 HTML 文件中,我尝试将<a>标签设置为href="index.html、href="/index/和href="/index",但这些选项都不起作用,而且我不确定是否<a href="index.html">有必要更改原始标签。(是吗?)
我尝试的另一个解决方案是利用该属性,如 @ken-mueller此处"redirects"建议的那样。我删除了“clearUrls”位并将以下内容放入我的 .json 文件中:
"hosting": {
"redirects": [ {
"source": "index.html",
"destination": "/index",
"type": 301
}, {
"source": "index.html{,/**}",
"destination": "/index",
"type": 3011
}, {
"source": "about.html", …Run Code Online (Sandbox Code Playgroud)