问题
I found in the firebase documents that you could hide the .html extensions of my site by creating a "firebase.json" file. I effectively remove the extensions but when I want to enter my other pages I cannot. I always see the main page.
I tried previously with .htaccess but it didn't work out. Now I found this firebase resource but any extension directs me to the main page.
I put that in my file "firebase.json"
"hosting": {
"cleanUrls": true,
"trailingSlash": false
}
回答1:
You can set up routes inside of firebase.json
. They can either be rewrites
(where the url is actually pointing to another location, but that is unknown to the user), or redirects
(where the page redirects to another url).
Inside of your firebase.json
, hosting
should look like this:
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/sign-up",
"destination": "/sign-up.html"
}
],
"redirects": [
{
"source": "/sign-up.html",
"destination": "/sign-up"
}
]
}
There are 2 added nodes, rewrites
and redirects
. What this does is whenever someone visits /sign-up
, you actually point them to /sign-up.html
, where your actual html code is. But when someone visits /sign-up.html
on their own, you redirect them to /sign-up
.
来源:https://stackoverflow.com/questions/57332661/is-there-a-way-to-remove-the-html-extensions-in-hosting-firebase