I have read lots of other related posts, but cannot understand what's wrong with the following code:
$(window).on("beforeunload", function () {
debugger
handleBeforeUnload();
return false;
});
function handleBeforeUnload() {
if (location.pathname != "/") {
location.assign(location.hostname + "/#" + location.pathname);
}
}
I have also tried a pure JavaScript approach without success. The underlying problem I am trying to solve is with angular "pretty" URLs. Although clicking links work fine, when reloading a page (ex. mydomain.com/about) I get a 404 Not Found error. I found that manually inserting a hashbang (mydomain/#/about) works correctly.
What am I missing here?