In Ember.js (version 1.0.0rc3) this can be accomplished by using the Ember.js location API:
App.Router.reopen({
location: 'history'
});
And then setting the web server to redirect traffic to the Ember application.
To give a concrete example here is a basic Apache .htaccess
file redirecting traffic to the Ember application located in index.html:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.html#$1 [L]
As Alex White points out Apache 2.2.16 and above supports a simpler configuration for redirecting traffic to a single target:
FallbackResource /index.html
The FallbackResource is part of the mod_dir
module and requires AllowOverride Indexes
to be set.
Make sure to test the application routes thoroughly. One common error is Uncaught SyntaxError: Unexpected token <
, which is caused by using relative links to CSS and JS files. Prepend them with a /
mark to make them absolute.
This functionality is not supported in Internet Explorer <10.