我有一个网站domain为例。我有Backbone.js的与pushstate和回退,当我转到domain/about它index.html页面和pushstates加载了约。一切工作。但如果我想转到里面像一个网页目录:www.domain/bio/moreinfo例如,它不工作,并抛出一个无效页。如果我做它在IE浏览器正常工作。我的htaccess文件有以下内容:
I have a website domain for example. I have backbone.js with pushstate and fallback and when I goto domain/about it loads up the index.html page and pushstates to about. everything is working. but if i want to goto a directory with a page inside like: www.domain/bio/moreinfo for example, it does not work and throws a invalid page. if i do it in IE it works fine. my htaccess file has the following:
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>如果我直接导航到该页面domain/bio/moreinfo它胡扯了(我想是因为我的服务器要转到这个生物目录?或者我需要实际控制骨干网的路由不同?它只是它适用于刘海所以它必须有一些怪异的推状态目录下的东西,其中#生物/信息是不一样的,以Apache作为/生物/信息。任何帮助是AP preciated。
if i navigate directly to the page domain/bio/moreinfo it craps out (i think because my server wants to goto the bio directory? or maybe I need to actually control the routes in backbone differently? its just that it works on bangs so it has to be some weird push state directory thing where #bio/info is not the same to apache as /bio/info . any help is appreciated.
推荐答案使用的答案在另一个建议后,这是要做好 &LT;基地的HREF =//&GT; 在index.html文件。这实际上提出的子目录我pushState的工作!只是有人建议..但随后在返回它打破了我的IE浏览器,但我固定它通过把额外的code。在我的骨干INIT
well using the answer in another suggested post, which was to do <base href="/" /> in the index.html file. This actually made the sub directories in my pushState work! just it was suggested.. but then in return it broke my IE, but i fixed it by putting extra code in my INIT of backbone
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()) }更多推荐
Backbone.js的PushState航线的.htaccess只是工作作为哈希,但无处
发布评论