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.
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'});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With