CodeIgniter:404错误导致500/Routes无效错误


CodeIgniter: 404 error causing a 500/Routes not valid error

我遇到了一个奇怪的问题。当我试图引起错误时,我会得到一些页面的500错误(这些页面不存在,我尝试它们只是为了引起404错误并测试它),有时我会得到实际的404错误页面。

这是我的.htaccess:

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index'.php|resources|images|css|js|robots'.txt|favicon'.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] AddHandler cgi-script .pl

这会导致这种情况吗?有人想过是什么原因造成的吗?我已将base_url设置为正确的域。问题似乎围绕着RewriteEngine和RewriteBase这两行,但我不知道如何配置它们。这个问题似乎不在我的路线上。如果我注释掉除默认控制器和404_override之外的所有控制器,我仍然会得到相同的错误:

Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.

在您的配置文件中,您是否确保将$config['base_url']设置为''?当使用干净的url时,这是必需的。

另一件需要尝试的事情是将$config['log_threshold']设置为4,这样您就可以开始查看错误的确切位置。

仅供参考这里是一个已知的好。htaccess

RewriteEngine on
RewriteCond $1 !^(index'.php|resources|robots'.txt|humans'.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

我建议您检查路由配置$route['default_controller']=valid controller。如果这没有造成错误,那么你可能会更改.htaccess.

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