Backbone.js PushState routes .htaccess only works as hash but nowhere else

I have a domain.com site for example. I have a backbone.js with pushstate and fallback and when I get domain.com/about it loads the index.html page and pushstates approximately. everything is working. but if I want to navigate to a directory with a page inside like: www.domain.com/bio/moreinfo for example it doesn't work and gives the wrong page. if i do it in IE it works fine. my htaccess file has this:

RewriteEngine on
# html5 pushstate (history) support: 
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L]
</ifModule>

      

if I go directly to the domain.com/bio/moreinfo page is it crappy (I think because my server wants to go to the bio directory?) or maybe I need to actually manage the routes in the spine differently? works on bangs, so this must be some kind of weird background information on where # bio / info is not the same for apache as / bio / info. any help is appreciated.

+3


source to share


1 answer


using the answer in another suggested post I should have done    <base href="/" />

in the index.html file. This actually made sub directories in my pushState work! just suggested .. but then in response it broke my IE, but I fixed it by adding extra code to my INIT trunk



 Backbone.history.start({ pushState: Modernizr.history, silent: true });
if(!Modernizr.history) {
    var rootLength = Backbone.history.options.root.length;
    var fragment = window.location.pathname.substr(rootLength);
    var search = window.location.search;
    Backbone.history.navigate('/#' + fragment + search, { trigger: true });
} else {
    Backbone.history.loadUrl(Backbone.history.getFragment())
}

      

+2


source







All Articles