经过数小时的研究和修修补补,我终于设法让backbone.js 路由正常工作,但有一个例外:如果我输入“/workingdir/routepath” - 一切都很好并且它使用“routpath”路由,但是如果我输入“/workingdir/routepath/”或“/workingdir/routepath/asdf”或任何类似的东西,我的网站中断,我收到看起来有点像这样的错误:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://example.com/staging/personal/css/style.css". fj:5
Resource interpreted as Script but transferred with MIME type text/html: "http://example.com/staging/personal/scripts/jquery-1.7.2.min.js". fj:6
Uncaught SyntaxError: Unexpected token < jquery-1.7.2.min.js:1
Resource interpreted as Script but transferred with MIME type text/html: "http://example.com/staging/personal/scripts/nav.js". fj:6
Resource interpreted as Script but transferred with MIME type text/html: "http://example.com/staging/personal/scripts/underscore-min.js". fj:6
Uncaught SyntaxError: Unexpected token < underscore-min.js:1
Resource interpreted as Script but transferred with MIME type text/html: "http://example.com/staging/personal/scripts/backbone-min.js". fj:6
Uncaught SyntaxError: Unexpected token < backbone-min.js:1
Uncaught SyntaxError: Unexpected token <
而且页面没有任何样式。我认为问题来自 URL 中的斜杠,使 css 和 js 文件的路径指向错误的位置(它们应该在“staging/css/”和“staging/scripts/”中,但正如日志所示,它正在寻找“staging/personal/xxx”)。
有想法该怎么解决这个吗?感谢您的时间!