4

我正在尝试让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文件。据我所知,我什至没有将这段代码放在正确的位置。

任何帮助将不胜感激!

4

1 回答 1

3

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

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

于 2012-07-10T19:28:24.863 回答