CodeIgniter Forums
set default controller in codeigniter 3 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: set default controller in codeigniter 3 (/showthread.php?tid=64558)



set default controller in codeigniter 3 - amardedhia020 - 03-04-2016

How to set $route['default_controller'] if i have subfolder in controllers ?
My directory structure is
controllers
---backend
------Login.php
------Users.php
---frontend
------Login.php
------Register.php
------Home.php

setting $route['default_controller'] = 'backend/login';

it is not working.
Please help


RE: set default controller in codeigniter 3 - ciadmin - 03-04-2016

The default controller is meant to identify the controller and method to use if one isn't specified in a URI ... http://www.codeigniter.com/user_guide/general/routing.html#reserved-routes

It is *not* meant to identify a subfolder!

In your case,
Code:
$route['default_controller'] = 'login';
tells CodeIgniter to use the Login controller in any subfolder accessed without specifying a controller, eg '/backend' or '/frontend'.

There has been lots of discussion about this on the forum, found by searching it...
http://forum.codeigniter.com/thread-64359.html?highlight=default+controller
http://forum.codeigniter.com/thread-64046.html?highlight=default+controller
http://forum.codeigniter.com/thread-63509.html?highlight=default+controller
http://forum.codeigniter.com/thread-63392.html?highlight=default+controller
and many more.