sehummel
sehummel

Reputation: 5568

Routing issue with 404_override

I'm having an issue with 404_override in CI 2.02. Here is my default controller and override:

$route['default_controller'] = "home/index_controller";    
$route['404_override'] = "misc/site_map";

This line uncommented gives me this error:

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

But commented, I get a 404 error. So something in the override is causing the problem. I just don't know what. I've tried various MY_Router files and they don't help. Anyone have any suggestions about how I can fix this?

I've eliminated my .htaccess file as the problem by deleting it from the server and then trying to access a controller that doesn't exist like this: http://domain.com/index.php/doesnotexist. I still get the error.

Upvotes: 1

Views: 8447

Answers (2)

Doug
Doug

Reputation: 3312

For anyone else coming here with this issue, this is/was a bug in CodeIgniter itself to do with 404 pages not being able to be included in subfolders.

Bug Discussion Including Fix on GitHub

Upvotes: 4

MacMac
MacMac

Reputation: 35341

You have forgotten to add the default controller that will be used when you first load your website, in your routes.php you need to add this, it is required which is why you're seeing the errors being thrown.

$route['default_controller'] = 'index'; // this will need to be changed to your default controller
$route['404_override'] = 'misc/site_map';

EDIT:

Okay, you must make sure you enter the correct controller name you wish to load as the default, for example you have home.php in your controllers folder, you must enter home as the default. Optionally, you can define segments that are functions in your home.php class file, e.g. home/function_name.

Upvotes: 0

Related Questions