Our platform is a unique combination of WordPress backend and AngularJS frontend, utilizing ui.router with html5 mode turned on and a base href="/" due to the stack sites being in the root of the site.
We are currently facing an issue:
1) Previously, when the otherwise("/") option was enabled and a state was not found (such as when a user clicked on a WordPress page or any other non-state defined page), the app would redirect to the main page "/"; 2) After removing this, everything seemed fine as we were able to access non-state pages directly through the URL like localhost/post/blah. However, now none of the links are working. Both ui-sref state links and regular a href="/whatever/whatever" links do not function. Although the browser's address bar changes to the appropriate link when clicked, nothing happens.
Our goal:
We aim to have the links work as originally intended - activate the state if one is found, and go to the intended link if no state exists.
We have tried various solutions found through Google searches and here, but have yet to find a fix. Most recently, we attempted:
$urlRouterProvider.otherwise(function() {
window.location.href = 'localhost'+window.location.pathname;
});
// This resulted in an endless loop of page reloads upon opening the page
We also tested:
$urlRouterProvider.otherwise(function() {
window.location.href = 'http://google.com'
});
//This code successfully redirected to another page, but the initial issue persisted. Therefore, we believe that the solution lies in firing the above function with the appropriate URL when no state is found, based on the link or address bar change. Any suggestions?