Reputation: 463
Trying to rewrite https://example.com with / (like https://example.com/) or without / at the end, to https://example.com/hello
Is it possible with javascript inside html? Don't want to rewrite any other matches
Upvotes: 0
Views: 189
Reputation: 392
You can use the window.history.pushState function.
here's an example for that
const state = { 'page_id': 1, 'user_id': 5 }
const title = 'NEW TITLE'
const url = 'https://example.com/hello'
window.history.pushState(state, title, url)
more data an examples in this link example.
Upvotes: 1