I am trying to implement accessible and bookmarkable URLs that are routed by angular.js.
This application can be accessed through a specific part of the website at http://example.com/application/
Anything that comes after /application/
is considered a route param.
My goal is to have a URL that can be accessed either by
http://example.com/application/#/filter1/filter2/filter3/
^ hashbang here
or
http://example.com/application/filter1/filter2/filter3/
^ no hashbang here
I would expect angular.js to pass these route params to my application, but instead it defaults to .otherwise.
Setting Up Basic Routes
$locationProvider.html5Mode(true); // this requires base-tag to be set in dom,
// but isn't working for me
$routeProvider
.when('/application/:filter1/:filter2/:filter3', {
action: 'filter',
reloadOnSearch: false
})
.otherwise({
redirectTo: '/application/' + filter1 + '/' + filter2 + '/' + filter3
});
In the HTML of the application, I added
<base href="/application/" />
, which seems to work initially. However, reloading the page or revisiting it after going through the .otherwise-route results in a "Page not found" error from the server.
If I disable HTML5 mode and remove the base-tag, it still doesn't function properly and I end up being routed through .otherwise.