I used firebase hosting to host my website. Recently I implemented a proof concept website usually operates with index.html & style.js only.
Functionality Info:
A single HTML+JS file used to host entire small scale website. I am able to modify html body content with javascript requests. But the problem is with reload button in browser. For example If I click about menu button then JS function will get the data for about from backend and shows. Show the url will be https://some.domain/about
.
Now If I refresh the page,
- It will go to 404 page by default.
- I used below redirection in
firebase.json
. But the result ishttps://some.domain
instead ofhttps://some.domain/about
with correct content page like what is showing while pressing about button.
Codes:
- Changing URL by manually by
history.pushState(null, null,
/about);
Redirection
firebase.json
"redirects": [ { "source": "/about", "destination": "/", "type": 301 }]
I want to keep dynamic functionality at the same time I want to keep specific url in address bar with content for that specific url.
How can I get it done?