![]() |
How can I use sub-controller WITHOUT providing the directory name? - 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: How can I use sub-controller WITHOUT providing the directory name? (/showthread.php?tid=62620) |
How can I use sub-controller WITHOUT providing the directory name? - pskovacs - 08-05-2015 I've read the docs and the forums, but I haven't yet figure out how to do this: http://siteA.com/ControllerA/someMethod --> handled by Controllers/ControllerA http://siteB.com/ControllerB/someMethod --> handled by Controllers/SubDirectory/ControllerB Controllers --ControllerA.php --ControllerA1.php --SubDirectory ----ControllerB.php ----ControllerB1.php The typical solution is to access: http://siteA.com/SubDirectory/ControllerB/someMethod But I don't want to specify SubDirectory, esp. since the controller is to be accessed via a different domain. Note that this worked in CI 2.X Thanks! RE: How can I use sub-controller WITHOUT providing the directory name? - CroNiX - 08-06-2015 With routes. PHP Code: $route['someMethodA'] = 'subdirectory/ControllerA/someMethod'; http://yoursite.com/someMethodA would then actually trigger /application/controllers/subdirectory/ControllerA/someMethod. RE: How can I use sub-controller WITHOUT providing the directory name? - pskovacs - 08-06-2015 (08-06-2015, 07:15 AM)CroNiX Wrote: With routes. Thank you! That works - but seemingly not with default_controller... $route['default_controller'] = $isSiteB ? 'SubDirectory/ControllerB/index' : 'ControllerA'/index; Success: http://siteB.com/SubDirectory/ControllerB/index 404: http://siteB.com (expecting it to trigger SubDirectory/ControllerB/index) Suggestion? |