2011-12-28 64 views
1

我想在godaddy webhosting(apache-linux ofcourse,不是IIS)上設置一個.htacess文件。但是,我真的堅持了一個問題:godaddy .htaccess重寫規則

RewriteEngine On 
Options +FollowSymLinks 
Rewriterule ^templates/.*$ - [PT] 
Rewriterule ^controllers/.*$ - [PT] 
Rewriterule ^.*$ index.php [NC,L] 

我真的得到一個內部服務器錯誤線路:

重寫規則^ * $的index.php [NC,L]

我不知道如何解決這個問題,我試過了我所知道的一切......基本上我想發送index.php中引導程序設置的任何東西。這是在任何託管我工作過,但曾嘗試,但godaddy似乎有這個問題:^。* $任何幫助,將不勝感激。

回答

0

此規則

重寫規則^ * $的index.php [NC,L]

看起來不錯,但要確保有標誌 即[NC, L]應之間沒有空格更改爲[NC,L]

你可以嘗試等同於看它是否有差別(你不需要NC因爲它已經匹配的任何請求)

Rewriterule .* index.php [L] 

如果這不是問題,那麼很可能之前的規則導致它失敗。評論他們兩個,看看是否可行,但增加的RewriteCond如下

Options +FollowSymLinks 
RewriteEngine On 

#if its not already index.php 
RewriteCond %{REQUEST_URI} !index\.php$ [NC] 
Rewriterule .* index.php [L] 

如果這些規則的真正原因,那麼我想知道什麼是與這些規則你的意圖,他們可以表達一種不同的方式,即如果意圖是重寫除模板或控制器目錄以外的所有內容,則可以通過以下方式實現:

#if request is not for templates or controllers directory 
RewriteCond %{REQUEST_URI} !^/(templates|controllers)/ [NC] 
Rewriterule .* index.php [L]