【发布时间】:2013-02-27 06:46:53
【问题描述】:
我正在尝试实现{ pushState : true },但它仅适用于基本路由,不适用于继续给我错误 404 的其他路由。
在 Chrome 中,如果我访问:
http://example.app/ - OK,显示控制台消息
http://example.app/show - 返回错误 404
我的路线是
var AppRouter = Backbone.Router.extend({
routes: {
'': 'index',
'show': 'show'
},
index: function() {
console.log('This is the index page');
},
show: function() {
console.log('This is the show page');
}
});
new AppRouter;
Backbone.history.start({pushState: true});
我的 .htaccess
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L]
</ifModule>
我错过了什么或我做错了什么?
【问题讨论】:
标签: backbone.js backbone-routing