Quite an odd situation here.
So I have two routes: /RouteA
(/
also defaults to here) and /RouteB
/RouteA
actually uses client side routing while /RouteB
does not if that matters.
When I try navigating to /RouteB
, the URL is initially /RouteB
which is correct.
Since IE9 doesn't support HTML5, Angular rewrites the url with a hashbang to /#/RouteB
When the rewriting occurs, it forces a browser refresh (can we stop this behavior?) which sends me right back to /
(which is ultimately /RouteA
.
Is there a way to prevent the browser from resending the request when the url is rewritten?
The base tag is currently <base href="/"/>
.
I tried doing something like this which allows me to land on the page, but breaks the anchor tag in the main menu thats trying to send me back to /RouteA
:
if (window.history && window.history.pushState) {
$locationProvider.html5Mode(true);
}
else {
window.location.hash = '/';
$locationProvider.html5Mode(false);
}
e.g. /#/RouteB
becomes /RouteB/#/
. Then clicking on a link back to /RouteA
, the route ends up becoming /RouteB/RouteA
which obviously breaks.
So I tried the solution from a similar question but it yielded the same results as above. $location / switching between html5 and hashbang mode / link rewriting
Does anyone have any ideas?
Thanks in advance!
/#/RouteB
. At some point it's going to have to go back to that anyway otherwise you'll end up with urls like/RouteB/#/RouteA
. The hashbang is a workaround for browsers that don't support pushstate, it's not going to be as pretty as pushstate. – Kevin B/RouteA
. The problem is that anything after the#
is ignored when a page is refreshed. So refreshingsomeSite.com/#/RouteB
is the same as going tosomeSite.com
as everything after the#
is ignored. – Garrett StevensonRouteA
andRouteB
with the default route of/
also leading toRouteA
.RouteA
is the default SPA that is hit when you navigate to this site. Hence why the refresh offoo.com/#/RouteB
is sending me back toRouteA
. Unfortunately that behavior cannot change. – Garrett Stevenson