Closed pauldijou closed 11 years ago
There is a way, is that what you had in mind?
var router = Router({
contact: State("/contact/:how?subject", function(params) {
router.redirect('newContact', params);
})
newContact: State("/something/contact/:how/more/stuff?subject", function(params) {
// do the actual work here
})
});
You could easily create a utility function called Redirect that creates a State which simply redirects to another: and then use it like that:
var router = Router({
contact: Redirect("/contact/:how?subject", 'newContact'),
...
});
Sounds good to me. The helper would be nice, this way you can control it in case you change your logic at some point.
Is there a way to support redirection? Let's say I had the following state:
But my boss wants to change all url of the site to:
It would be awesome to no display a 404 on the old url but rather redirect to the new one, keeping all params and query string and hash of couse.
It would also be useful for "notFound" state, if you want to redirect to home page rather than display a 404 page.