2013-02-13 144 views
1

我在我的網絡服務器上安裝了一個CodeIgniter項目(http://sample.org/myproject/)。.htaccess無法正常工作

對於CodeIgniter的路由規則(例如index.php/controller/methode)我在使用RewriteEngine的myproject文件夾中編寫了一個.htaccess文件。該文件是建立如下:

AuthType Basic 
AuthUserFile /home/www/myuser/html/myproject/.htpasswd01 
AuthName "secured area" 
require valid-user 
Options -Indexes 
Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$0 [PT,L] 

現在的問題我已經得到了:如果我把正常的頁面(http://sample.org/myproject/index.php/somestuff),它工作正常,但在現階段,我只能直接調用該目錄(http://sample.org/myproject/),這隻會工作一些特定的時間。有時它會起作用(在顯示此錯誤的特定時間之後),有時它不起作用。

這是否與瀏覽器重新讀取.htaccess的時間有關?

+0

嘗試改變'重寫規則*的index.php/$ 0 PT,L]''要重寫規則^ $的index.php/$ 1 [ PT,L]' – 2013-02-13 07:30:01

+0

myproject其實是您的$ DOCUMENT_ROOT下的一個真實目錄? – anubhava 2013-02-13 08:50:51

+0

@anubhava是的,這是一個現有的.htaccess-File文件夾。 – 2013-02-13 08:56:03

回答

0

由於myproject實際上是在你的$DOCUMENT_ROOT一個真正的目錄,你有RewriteCond %{REQUEST_FILENAME} !-d在你的.htaccess(也就是說,如果要求不是一個目錄執行),因此您的重寫規則甚至沒有開火。

這個替換現有代碼:(。*)

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule . index.php/$0 [NC,L]