在 Ember.js(版本 1.0.0rc3)中,这可以通过使用来完成Ember.js 定位 API http://emberjs.com/guides/routing/specifying-the-location-api/:
App.Router.reopen({
location: 'history'
});
然后设置 Web 服务器将流量重定向到 Ember 应用程序。
这里举一个具体的例子是一个基本的Apache.htaccess
将流量重定向到位于 index.html 中的 Ember 应用程序的文件:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.html#$1 [L]
As 亚历克斯·怀特 https://stackoverflow.com/a/21704913/657661指出 Apache 2.2.16 及更高版本支持更简单的配置,用于将流量重定向到单个目标:
FallbackResource /index.html
The 后备资源 https://httpd.apache.org/docs/trunk/mod/mod_dir.html#FallbackResource是的一部分mod_dir
模块和要求AllowOverride Indexes
要设置。
确保彻底测试应用路线。一个常见的错误是Uncaught SyntaxError: Unexpected token <
,这是由于使用CSS和JS文件的相对链接造成的。在它们前面加上一个/
标记以使它们绝对。
这个功能是Internet Explorer . http://caniuse.com/#search=pushstate