Reputation: 2965
Suppose I have the following URL.
www.mywebsite.com/foo/abc/def
And in my router, it might look something like this:
this.route('foo', function() {
this.route('fooo');
this.route('foooo');
this.route('abc', function() {
this.route('def');
this.route('def, {path: 'def.html'});
// Some other routes
}
// Some other routes
}
// Some other Routes
So what happens now if I want my foo/abc/def
to redirect to somewhere COMPLETELY different. Like, for example, bar/uvw/xyz
. How can I redirect to there? Is there a way to do it from a the router? I could write transition logic within the /foo/abc/def
route but that seems a bit messy.
The reason I need to do this is because I'm transitioning one of our companies websites to a new Ember site. And we want to change the routes to some of our products but make sure people who have saved links to those webpages won't get dead-links.
Upvotes: 0
Views: 61
Reputation: 18682
You can't do that from the router. You need to place your redirects inside JavaScript code of your Route.
As @locks suggested it might be a good place for you to start with reading Redirecting guides.
Upvotes: 2
Reputation: 18090
I know that this isn't always an option, but you may want to look at having the web server do this (nginx, Apache, S3, whatever you're using).
The main benefit of this is that your Ember app doesn't need to load at all to make the redirection decision. Also, it keeps your Ember router code cleaner, not worrying about representing the old application's URL structure.
Upvotes: 1