How to change my url from https://example.com/name.html
to https://example.com/name
?
I am using Firebase Hosting to host my website. The site is made in HTML and javascript using bootstrap studio.
After reading various solution online, i know that '.htaccess' file can be used to change the url but none of the solution provide a way to do it with Firebase Hosting.
Firebase Hosting has a setting called cleanUrls
that controls the presence/absence of the HTML extension. See the documentation on controlling .html extensions:
The
cleanUrls
attribute allows you to control whether or not URLs should include the.html
extension.
When true, Hosting automatically drops the
.html
extension from uploaded file URLs. If an.html
extension is added in the request, Hosting performs a301
redirect to the same path but eliminates the.html
extension.
Specify the inclusion of
.html
extensions by including a cleanUrls attribute within hosting in yourfirebase.json
file. For example:
"hosting": { // ... // Add the "cleanUrls" attribute within "hosting" "cleanUrls": true }