【问题标题】:Backbone.js router using pushstate with XAMPP apache server on localhostBackbone.js 路由器在 localhost 上使用 pushstate 和 XAMPP apache 服务器
【发布时间】:2012-07-09 09:55:00
【问题描述】:

我正在尝试让backbone.js 的路由器与我在本地主机上的XAMPP apache 服务器一起工作。

我需要阻止 apache 评估应该进入路由器的目录路径,并将所有内容转发到 /test_backbone/index.html。我已经尝试了所有能找到的方法,但没有任何效果。

目前,我在 httpd.conf 文件中有这个:

# html5 pushstate (history) support:
<ifModule mod_rewrite.c>
  Options +FollowSymLinks
  IndexIgnore */*
  # Turn on the RewriteEngine
  RewriteEngine On
  #  Rules
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule (.*) /test_backbone/index.html
</ifModule>

我也试过这个:

# 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>

我的印象是其中一些行应该说加载静态文件(如果存在),但我的任何 javascript 文件都没有被加载,一切都回到/test_backbone/index.html

我也尝试过.htaccess 文件。据我所知,我什至没有把这段代码放在正确的地方。

任何帮助将不胜感激!

【问题讨论】:

    标签: apache .htaccess backbone.js xampp backbone-routing


    【解决方案1】:

    您的配置应该可以工作。修改httpd.conf时需要重启apache 修改.htaccess时无需重启。

    以防万一,尝试将“[L]”标志添加到httpd.conf 的重写规则中,以便在匹配后停止处理更多规则。

    【讨论】:

      猜你喜欢
      • 2012-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-24
      • 2017-09-10
      • 2021-06-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多