Codeigniter默认控制器无法正常工作

时间:2012-01-30 23:59:43

标签: php codeigniter controller

我几乎使用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 设置为默认控制器,因此以下网址将直接指向默认控制器:

http://localhost/readme

对于生产,我使用与开发相同的配置,但以下网址不起作用并生成“目录访问被禁止”错误:

http://www.mydomain/readme

相反,我必须使用

http://www.mydomain/readme/readme_home

显示默认控制器。有没有丢失的配置?如果有人可以在网上指出有关此问题的任何参考,那就足够了。如果我必须添加其他信息,请与我们联系。谢谢先生,我真的很感激。

1 个答案:

答案 0 :(得分: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';