Unablex to load your default controller. Please make sure the controller specified in your Routes.php file is Valid. Codeigniter

Asked

Viewed 31 times

3

This error appears when Load in the Initial method:

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

And I’m running the project localhost and it works perfectly. But on the server, it doesn’t work. I tried to change the PHP version to lower or higher, it didn’t work either.

I’m routing using third_party mx

Routes.php

$route['default_controller'] = 'inicial/inicial';
$route['404_override'] = 'inicial/erro';

I tried to replace initial/initial with just initial. It didn’t work either. What would be wrong? If locally it works perfectly.

I’m using Codeigniter to render the project.

1 answer

1


Incredible as it may seem, I got the solution as follows: Accessing the file system/core/codeigniter.php

I looked for the error mentioned:

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

and found:

if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'))
{
    show_error('Unablex to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
}

Then replace it with:

$arquivo = str_replace("..", "", APPPATH.$RTR->fetch_directory().$RTR->fetch_class().'.php');
if ( ! file_exists($arquivo))
{
    show_error('Unablex to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
}

That way I forced the framework to search the file in the "correct" way, and in this case it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.