N
N
Nikita Souvel2016-07-19 15:58:09
CodeIgniter
Nikita Souvel, 2016-07-19 15:58:09

Why might overriding default_controller not work if the controller is not in the controllers folder?

There was a problem.
It is done in such a way that the site admin panel is located separately on a subdomain, but the "soul" of the project is a single codeigniter, everything would be fine, but for some reason default_controller can only be set if the controller is in the controllers folder, otherwise it generates a 404 error.
I give all the information (in this case, 404 occurs):
SUBDOMAIN = admin; (the constant is defined earlier and 100% is equal to admin in a specific case, not the point)

switch(SUBDOMAIN)
{
  case 'admin':
    $route['default_controller'] = 'admin/dashboard';
    $route['translate_uri_dashes'] = FALSE;
    break;

  ...
}

The server logs show the following:
INFO - 2016-07-19 15:46:56 --> Config Class Initialized
INFO - 2016-07-19 15:46:56 --> Hooks Class Initialized
DEBUG - 2016-07-19 15:46:56 --> UTF-8 Support Enabled
INFO - 2016-07-19 15:46:56 --> Utf8 Class Initialized
INFO - 2016-07-19 15:46:56 --> URI Class Initialized
INFO - 2016-07-19 15:46:56 --> Router Class Initialized
INFO - 2016-07-19 15:46:56 --> Output Class Initialized
INFO - 2016-07-19 15:46:56 --> Security Class Initialized
DEBUG - 2016-07-19 15:46:56 --> Global POST, GET and COOKIE data sanitized
INFO - 2016-07-19 15:46:56 --> CSRF cookie sent
INFO - 2016-07-19 15:46:56 --> Input Class Initialized
INFO - 2016-07-19 15:46:56 --> Language Class Initialized
ERROR - 2016-07-19 15:46:56 --> 404 Page Not Found: /index

I checked the file naming, for example /admin/dashboard is available

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question