Reputation: 21
I have an Ember app where I am renaming a few routes. I am concerned users may have the old routes bookmarked. Where is the best place to handle redirects from the old route to the new one?
Upvotes: 1
Views: 272
Reputation: 458
What you probably want is replaceWith
: replaceWith documentation
you would use it like this:
// app/router.js
Router.map(function() {
this.route('old-route');
this.route('new-route');
});
// app/routes/old-route.js
export default Route.extend({
beforeModel() {
this.replaceWith('new-route');
}
});
Now, if what you wanted to do is KEEP the original route (which it doesn't sound like you want to do but I mention it for completeness) is use ember-route-alias
further reading: Ember guide on redirecting
Upvotes: 2