window.top.addEventListener('popstate', function(event) { if(!!event.state) window.location = event.state; }); $(document).ready(function() { window.top.history.replaceState(window.location.pathname, null, '/mc' + window.location.pathname); });