javascript - Backbone Router + RewriteRule not triggering route with a "/" -
i convert links example.com/action
example.com/index.html#action
parsed backbone router.
however, new page, signup/:inviteauthhash
(eg. signup/9d519a2005b3dac8802d8e9e416239a1
) not working; thing renders index.html
, , none of breakpoints in router met.
.htaccess:
# not 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]
router.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'); // navigate 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 };
can try .htaccess instead:
# not 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]
Comments
Post a Comment