To add and modify history, use history.pushState()
and history.replaceState()
methods, respectively.
window.history.pushState('username2', 'Title', '/username2.php');
To know more visit: History API
The only way to create single page apps is to use Angular JS. To know more visit: Angular JS
5
solved PHP – How do facebook change the facebook/message/username to facebook/message/username2 on the same page? [duplicate]