user6481062
user6481062

Reputation: 463

Is there a way to rewrite naked domain url in html javascript

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

Answers (1)

dahan raz
dahan raz

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

Related Questions