我将所有链接转换为example.com/action
to example.com/index.html#action
然后由我的主干路由器解析。
然而,我的新页面,signup/:inviteAuthHash
(eg. signup/9d519a2005b3dac8802d8e9e416239a1
) 不管用;唯一呈现的是我的index.html
,并且我的路由器中的断点都没有得到满足。
.htaccess:
# not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# example.com/home => example.com/index.html#home
RewriteRule ^(.+)$ index.html#$1 [L,QSA]
路由器.js
var AppRouter = Backbone.Router.extend( {
routes : {
/* PAGES */
// beta
'request_invite' : 'request_invite',
'signup/:inviteAuthHash' : 'signup',
// Default
'*actions' : 'defaultAction'
},
/* PAGES */
// eta
request_invite : function() {
new BetaLayout;
new RequestInviteView;
},
signup : function(inviteAuthHash) {
// validate auth hash
if(!InviteRequest.isValidInviteAuthHash(inviteAuthHash))
return this.defaultAction();
else {
new BetaLayout;
new SignupView(SignupView);
}
},
// Default
defaultAction : function(actions) {
app_router.navigate('request_invite');
this.request_invite();
}
});
var initialize = function() {
app_router = new AppRouter;
$('a').live('click', function() {
var href = $(this).attr('href');
// only navigate to real links
if(href == undefined)
return;
// open in new window?
if($(this).prop('target') == '_blank')
return true;
app_router.navigate(href, {trigger: true});
return false;
});
Backbone.history.start({pushState: true});
};
return {
initialize : initialize
};
你可以试试这个 .htaccess 吗:
# not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
# example.com/home => example.com/index.html#home
RewriteRule (?!^index\.html)^(.+)$ /index.html#$1 [L,NC,R,NE]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)