.htaccess - 重定向无法按预期工作

时间:2015-02-03 19:49:17

标签: apache .htaccess redirect hashtag mediatemple

我无法在我的网站上使用此功能:

# BEGIN pushState Routing
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SERVER_PORT} 80 

RewriteRule ^/tournament/(0-9)+$ /#tournament/$1 [R=301,NE,L]
# END pushState Routing

当我...example.com/tournament/11时,我会收到404.它应该重定向到example.com/#tournament/11,以便Backbone.js启用pushState并删除主题标签。

1 个答案:

答案 0 :(得分:0)

试试这段代码:

# BEGIN pushState Routing
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SERVER_PORT} =80 
RewriteRule ^/?(tournament/\d+)/?$ /#$1 [R=301,NE,L,NC]
# END pushState Routing

.htaccess中的前导斜杠不匹配,所以最好使其与.htaccess和Apache配置兼容。