2012-01-30 96 views
0

我幾乎已經完成了一個使用Codeigniter的Web應用程序。在發展中,根目錄是/自述/我用下面的代碼在.htaccess以消除網址的index.php:Codeigniter默認控制器不工作

RewriteEngine On 
RewriteBase /readme 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php/$1 [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

我還設置Readme_home作爲默認的控制器,所以直接下列URL將指向默認控制器:

http://localhost/readme 

對於生產,我使用了完全相同的配置作爲一個發展,但下面的網址無法正常工作,併產生「目錄訪問被禁止「的錯誤:

http://www.mydomain/readme 

相反,我不得不使用

http://www.mydomain/readme/readme_home 

爲默認的控制器出現。是否有任何缺失的配置?如果任何人都可以在網上指出這個問題,那就足夠了。讓我知道是否必須添加其他信息。謝謝先生,我真的很感激。

+0

檢查文件夾和文件權限,它必須對Web訪問可讀(例如,chmod 666)。 有關該主題的更多信息[搜索引擎](http://www.google.de/search?q=codeigniter+「Directory + access + is +禁止」)。 – 2012-01-31 08:05:56

+0

我不認爲這是一個權限問題。你有沒有嘗試過使用標準的.htaccess腳本(或沒有.htaccess文件),只是將你的配置中的base_url改爲「http://www.mydomain.com/readme 」?我認爲CI應該將其餘的自行排序。 – 2012-01-31 09:34:46

+0

我實際上嘗試了兩種方法,但那些方法不起作用。謝謝:) – vandershraaf 2012-02-01 01:24:38

回答

0

嘗試:

$RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA] 

根據您的主機上,你uri_protocol可能無法正確檢測。在config/config.php文件中,將uri_protocol切換到列出的任何選項。在VPS上運行我的應用時,我遇到了同樣的問題。目前,PATH_INFO的作品。

/* 
|-------------------------------------------------------------------------- 
| URI PROTOCOL 
|-------------------------------------------------------------------------- 
| 
| This item determines which server global should be used to retrieve the 
| URI string. The default setting of 'AUTO' works for most servers. 
| If your links do not seem to work, try one of the other delicious flavors: 
| 
| 'AUTO'   Default - auto detects 
| 'PATH_INFO'  Uses the PATH_INFO 
| 'QUERY_STRING' Uses the QUERY_STRING 
| 'REQUEST_URI'  Uses the REQUEST_URI 
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO 
| 
*/ 
$config['uri_protocol'] = 'PATH_INFO'; 
+0

我也嘗試過,但仍然沒有運氣。我同意這可能是codeigniter配置或.htaccess。任何其他想法? – vandershraaf 2012-02-01 01:34:32