2012-01-13 170 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]