2011-09-21 66 views
0

我一直在努力嘗試,並找不到解決方案,這肯定很容易。我有規則mod_rewrite - 除靜態文件夾以外的所有索引

RewriteEngine on 
RewriteRule (.*) index.php [L] 

所以它重定向所有URL的index.php,現在我希望所有的文件預計這種靜態文件夾重定向,所以像domain.com/static網址/ ...不會被重定向。我試過,例如:

RewriteEngine on 
RewriteCond %{REQUEST_URI} !^static$ 
RewriteRule (.*) index.php [L] 

RewriteEngine on 
RewriteRule static/(.*) static/$1 [L] 
RewriteRule (.*) index.php [L] 

和其他一些變化,但似乎沒有任何工作...

+0

你最後的規則集對我來說看起來是否正確,你是否嘗試[R,L]而不是[L]? –

+0

[R,L]不起作用... – f1ames

回答

2

在您正則表達式,使用負前瞻

RewriteEngine on 
RewriteCond %{REQUEST_URI} ^(?!/static/).+ [NC] 
RewriteRule (.*) index.php [L] 
+0

你確定它有效嗎?如果答案是「是」,這意味着我的服務器不喜歡我...... – f1ames

+0

我在IIS服務器上使用mod_rewrite的ISAPI插件測試了它。它應該和apache的語法相同。如果對你沒有好處,在「靜態」之前不要使用斜線。如果仍然不好,我會收回我的答案:-( – Jamey

+0

哦,無論我的重寫規則是否有效,我很確定你的服務器恨你 – Jamey

相關問題