Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Backbone.js PushState routes.htaccess仅用作哈希,其他任何地方都不能_.htaccess_Backbone.js_Routes_Pushstate_Hashbang - Fatal编程技术网

Backbone.js PushState routes.htaccess仅用作哈希,其他任何地方都不能

Backbone.js PushState routes.htaccess仅用作哈希,其他任何地方都不能,.htaccess,backbone.js,routes,pushstate,hashbang,.htaccess,Backbone.js,Routes,Pushstate,Hashbang,例如,我有一个网站domain.com。我有带有pushstate和fallback的backbone.js,当我转到domain.com/about时,它会加载index.html页面并将pushstates设置为about。一切正常。但是如果我想转到一个目录,里面有一个页面,比如:www.domain.com/bio/moreinfo,它就不起作用,并抛出一个无效页面。如果我用IE做的话,效果很好。我的htaccess文件包含以下内容: RewriteEngine on # html5 pu

例如,我有一个网站domain.com。我有带有pushstate和fallback的backbone.js,当我转到domain.com/about时,它会加载index.html页面并将pushstates设置为about。一切正常。但是如果我想转到一个目录,里面有一个页面,比如:www.domain.com/bio/moreinfo,它就不起作用,并抛出一个无效页面。如果我用IE做的话,效果很好。我的htaccess文件包含以下内容:

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>
重新编写引擎打开
#html5 pushstate(历史)支持:
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_URI}!指数
重写规则(.*)index.html[L]

如果我直接导航到domain.com/bio/moreinfo页面,它就会退出(我想是因为我的服务器想转到bio目录?或者我需要实际控制主干网中的路由不同?只是它在bang上工作,所以它必须是一些奇怪的推送状态目录,其中#bio/info与apache的/bio/info不同。任何帮助都是非常感谢的。

好吧,在另一个建议中使用这个答案ed post,该怎么办
在index.html文件中。这实际上使我的pushState中的子目录正常工作!正如建议的那样..但作为回报,它破坏了我的IE,但我通过在主干的INIT中添加额外代码来修复它

 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())
}

昨天有一个家伙也有同样的问题,除了他在做除IE以外的所有事情。你们一起有一个正在工作的路由器,恭喜你们。