Welcome Guest, Not a member yet? Register   Sign In
URL shows error 404 instead of default controller


I'm looking for a bit of guidance with this one, as it's proving to be a bit tricky!

My set up is as follows:
  • I have /application and /system in a non-public folder
  • I have two URLs (at the moment): example.com and another.example.com
  • In my public_html folder, I have index.php and /another/index.php (for the subdomain) - both pointing to the same application and system folder (essentially, two sites running same config etc.). I'm not sure if this is the best approach, but having tried a few, this is the only one that works (except the issue below)
  • Both config and routes are set up to check $_SERVER['HTTP_HOST'] and set the values based on this
  • All controller files for 'another.example.com' are stored in /controllers/another/
So, in my routes.php file, I have the following:
PHP Code:
$route['404_override'] = '';
$route['translate_uri_dashes']             = TRUE;

if (
strstr($_SERVER['HTTP_HOST'], 'another.example.com')) {
$route['default_controller']     = "another/login/index";
$route['(.+)']             = 'another/$1';
$route['default_controller'] = "welcome";

However, visiting just 'another.example.com' shows a 404 rather than /another/login

Hopefully I've given more than enough info, but knowing me I've missed something simple!

Any help appreciated!


Not sure if this is the cause of your problem, but your controllers directory can only have files or one sub level of folders. So a controller called login can be in controllers/login.php or controllers/members/login.php but not controllers/another/members/login.php as CI will assume 'members' is the class name in that case.

I hope that makes sense and might be of some help,

Best wishes,


Hi Paul,

Thanks for your reply!

Login.php (the controller) is stored at /controllers/example/Login.php.

However, on that note, I do have other folders in /example/ and they seem to load fine. I'm guessing that's not intended judging by your post, but it seems to work. I weren't aware that it was limited to one level of sub-folders for controllers so I just done what I thought would be best organisation wise.

But thank you for your suggestion Smile

Theme © iAndrew 2016 - Forum software by © MyBB