[英]Codeigniter default controller not working
我幾乎已經使用Codeigniter完成了一個Web應用程序。 在開發中,根目錄是/ readme / ,我在.htaccess中使用以下代碼來消除URL中的index.php:
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
對於生產,我使用與用於開發的配置完全相同的配置,但是以下URL不起作用並產生“ 禁止目錄訪問 ”錯誤:
http://www.mydomain/readme
相反,我必須使用
http://www.mydomain/readme/readme_home
默認顯示的控制器。 是否有缺少的配置? 如果任何人都可以在網絡上指出有關此問題的任何參考資料,那就足夠了。 讓我知道是否需要添加其他信息。 謝謝您,先生,我真的很感激。
嘗試:
$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';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.