2012-01-08 34 views

回答

2

像这样的东西?

# not existing file (images, css, etc) 
RewriteCond %{REQUEST_FILENAME} !-f 
# no query parameters 
RewriteCond %{QUERY_STRING} ="" 
# not/
RewriteCond %{REQUEST_URI} !^/$ 
# external redirect and pass along query string and uri as fragment 
# i guess this must be an external redirect as the server side should 
# not see the fragment, R=redirect, NE=dont escape #, L=last rule 
RewriteRule ^(.*)$ /#!/$1 [R,NE,L] 

# same but with query parameter 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !^/$ 
RewriteRule ^(.*)$ /?%{QUERY_STRING}#!/$1 [R,NE,L] 

但我不知道这是否好主意。也许你应该在应用程序逻辑或客户端脚本中进行重定向。

+0

这不行! – 2012-01-08 12:36:10

+0

我现在修正了标志语法,那是什么没有工作? – 2012-01-08 13:04:12

+0

当我测试时,它没有显示片段部分。我会再试一次,让你知道。 – 2012-01-08 16:40:00