1

I want to visually (not affecting real address) change URL in browser address bar, like this:

Real:  http://www.example.com/example_a_b_c.html
Shown: http://www.example.com/e_a_b_c

(I may also want to change domain name, if I could)

It would be much nicer if there is an option to use any simple Javascript code or function. I don't actually know the language, so I'm only looking for a little code that would fit into an HTML <script> tag, just for myself.

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128

1 Answers1

1

You can achieve this using the History API, and, more precisely, using the history.pushState() method.

An example of this, in your case, would be:

history.pushState(null, null, '/e_a_b_c');

To answer your other question:

I may also want to change domain name, if I could.

Unfortunately you can't, that would be a huge security flaw, and it's not possible at all.

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128