Reputation: 17596
I use Meteor 1.0 and iron:router. I currently redirect users with the following 2 routes definitions:
Router.route('/', function () {
this.render('home_page');
});
Router.route('/about', function () {
this.render('about');
});
How can I define a route for undefined routes (error 404) ? For instance, if a user go to the url "/blablabla", I want him to be redirected to /404 which would refer to a template.
Upvotes: 6
Views: 2062
Reputation: 9523
I used to have a catch-all route defined ("/*"
) but that stopped working with my update to Meteor 1.0, so went looking for a better way and I noticed that you can configure a notFoundTemplate
. That seems to do the trick for me. It use the layoutTemplate
as the base and just fills in the yield
with the notFoundTemplate
which is exactly what I wanted.
Router.configure({layoutTemplate: 'layout', notFoundTemplate: '404'});
Upvotes: 16
Reputation: 151916
There is a dataNotFound
iron-router plugin that deals with undefined routes:
https://github.com/EventedMind/iron-router/blob/devel/Guide.md#plugins
Upvotes: 0