2012-01-13 109 views
1

我有一个奇怪的问题。当我尝试导致错误时,我收到了一些500页的错误(这些错误不存在,我只是试图导致404错误并进行测试),然后有时会出现实际的404错误页面。CodeIgniter:404错误导致500 /路由无效错误

这里是我的.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.

+0

你得到的Apache 404或CodeIgniter 404? – landons 2012-01-13 22:37:30

+0

我不明白。我收到“路由无效”消息。我有一个404_override设置为我的控制器之一。 – sehummel 2012-01-16 18:41:05

+1

你想要达到什么URL /控制器,你的路线是什么样的? – tgriesser 2012-01-16 18:45:37

回答

0

在您的配置文件中有你确信在$配置[“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] 
0

我建议你应该检查路由配置$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]