2012-01-08 70 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