I am currently trying to make an angular app indexable by implementing the _escaped_fragment_-scheme (Google Docs). I am aware of the fact that it is deprecated but as far as I can tell after some research and experiments it is still the safest bet.
The scheme requires the hashbang #!
as the delimiter for the 'real URI' and the angular routing part of the URI, i.e.
http://www.someuri.com/#!/dashboard
Currently I use the default #:
http://www.someuri.com/#/dashboard
I know how to change the routing to use '#!':
angular.module('myApp').config([
'$locationProvider',
function($locationProvider) {
$locationProvider.hashPrefix('!');
}
]);
However, this obviously breaks 'old' links (like http://www.someuri.com/#/dashboard).
How can I route both URI formats correctly?
I have tried to configure the routing like this:
app.config(function($urlRouterProvider) {
$urlRouterProvider
.when('!/imprint', '/imprint')
.when('!/blog', '/blog')
.when('!/blog/{blogPostId}', '/blog/{blogPostId}');
});
but it doesn't work, neither can I define states with an exclamation mark as the first character of the route's URI.