This should work, pass in the specific paths you want the user to be redirected on:
var reservedPaths = ['/explore','/teachers','/reports'];
if (rejection.status === 401 && _.contains(reservedPaths,$location.path().trim()) {
$location.path('/welcome');
}
Or you could use $state.includes()
if you want to work with ui-router's
states. Provide a small plunk to demonstrate the issue if the above doesn't work.
Regarding @Kanh TO's comment about the client being able to view unauthorized pages, what we do is we handle the restricted routes client side, but our web API endpoints check requests for authentication/authorization, so even if the user does fiddle with this and manage to arrive at unauthorized routes, they'll simply see a view with no data, which in my opinion is no big deal since the data is what you want unauthorized users to not see, not your app's views.