javascript - HTML5 pushState with Backbone.js router not working on specific server but working on others -


been pulling hair out on issue. can't seem find out why pushstate router not working on our development server while works on 2 other real servers (staging , client's live domain) , works local mamp server.

here's router:

    jquery(function(){         // define routes         var router = backbone.router.extend({            routes: {                 '': 'chrono',                 ':number': 'chrono',                 ':number/plus': 'chrono'            },            // load views           initialize: function() {               backbone.history.start({                   pushstate: true,                   hashchange: false     // use html5 pushstate hashchange set false                                         // handle navigation of hash anchors             });           },            chrono: function(number) {                 url = window.location.hash.split("/");                  this.reset();                 this.content = new chronoview();                  if(number == undefined){                     number = 0;                 }                 if(url[1]=="plus") {                     this.content.showmiddlebox();                     jquery('#overlay2').show();                 }           },            reset: function() {                 if (this.content != undefined){                     this.content.hide();                  }           }       });        var router = new router;     }); 

my .htaccess file on non-working server have quite few engine re-write rules already, , file 200+ lines here's deem relevant parts:

    # block access "hidden" directories names begin period.     # includes directories used version control systems such subversion or git.     <ifmodule mod_rewrite.c>       rewritecond %{script_filename} -d       rewritecond %{script_filename} -f       rewriterule "(^|/)\." - [f]     </ifmodule>      <ifmodule !mod_rewrite.c>         # if don't have mod_rewrite installed, 404's         # can sent index.php, , works normal.         # submitted by: elliothaughin          errordocument 404 index.php     </ifmodule>      # url , hash rewrite backbone     # used html 5 pushstate support *not working*     <ifmodule mod_rewrite.c>         rewriteengine on         rewritecond %{request_filename} !-f         rewritecond %{request_filename} !-d         rewritecond %{request_uri} !index         rewriterule (.*) index.html [l]     </ifmodule> 

/* edit */

after comparing .htaccess file of non-working server against working server.htaccess i've not had success, both files same except accounting subfolder paths. i.e.:

working server: rewriterule ^(.*)$ index.php?/$1 [l] non-working server: rewriterule ^(.*)$ dj24/index.php?/$1 [l]

and that's difference between 2 files, makes sense because client's version (working .htaccess) hosted on subdomain no subfolder, i.e. http://subdomain.clientsdomain.com/ whereas our development server version hosts project on subfolder path subdomain, i.e. http://dev.our_domain.com/ourapplication

i'm starting believe it's subdomain + subfolder combo that's causing issue. appreciated. thanks!

since main difference between working project , 1 doesn't folder structure , using configuration httaccess not solve issue, try setting folder root router, had similar issue few months ago can't recall was(but remember related using subfolder inside domain , backbone), suggestion, might or might not help, in case did.

first base folder

var basefolder =  window.location.pathname.replace('/','').split('/')[0]; 

then use router root

routes: {     '(:number)(/plus)': 'chrono' },  initialize: function() {     backbone.history.start({         pushstate: true,         hashchange: false,         root: basefolder                                            });  }, 

let me know if helps =)


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -