Here is an example:
I am defining the last route in my router using a wildcard pattern: http://emberjs.com/guides/routing/defining-your-routes/#toc_wildcard-globbing-routes
I have a /not-found route, see the last route defined in my /*path router to catch any text string, see https://github.com/pixelhandler/blog/blob/master/client/app/ router.js # L19
Router.map(function () { this.route('about'); this.resource('posts', function () { this.resource('post', { path: ':post_slug' }); }); this.resource('admin', function () { this.route('create'); this.route('edit', { path: ':edit_id' }); }); this.route('not-found', { path: '/*path' }); });
This route redirects to /not-found , see https://github.com/pixelhandler/blog/blob/master/client/app/routes/not-found.js
import Ember from 'ember'; export default Ember.Route.extend({ redirect: function () { var url = this.router.location.formatURL('/not-found'); if (window.location.pathname !== url) { this.transitionTo('/not-found'); } } });
Also, any route that has a hook (e.g. model , beforeModel , afterModel ) that gives a rejected promise can use the error action to jump to 404.
actions: { error: function (error) { Ember.Logger.error(error); this.transitionTo('/not-found'); } }
What the not-found template does, see https://github.com/pixelhandler/blog/blob/master/client/app/templates/not-found.hbs
<h1>404 Not Found</h1> <p> Perhaps you have a link that has changed, see {{#link-to 'posts'}}Archives{{/link-to}}. </p>
Here is my 404 page: http://pixelhandler.com/not-found
pixelhandler Aug 28 '14 at 21:30 2014-08-28 21:30
source share