Backbone.js的PushState航线的.htaccess只​​是工作作为哈希,但无处

编程入门 行业动态 更新时间:2024-10-20 07:53:02
本文介绍了Backbone.js的PushState航线的.htaccess只​​是工作作为哈希,但无处的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个网站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只​​是工作作为哈希,但无处

本文发布于:2023-11-01 18:07:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550035.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:航线   工作   js   Backbone   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!