Welcome Guest, Not a member yet? Register   Sign In
How can I use sub-controller WITHOUT providing the directory name?
#1

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!
Reply
#2

(This post was last modified: 08-06-2015, 07:15 AM by CroNiX.)

With routes.

PHP Code:
$route['someMethodA'] = 'subdirectory/ControllerA/someMethod';
$route['someMethodB'] = 'subdirectory/ControllerB/someMethod'

http://yoursite.com/someMethodA would then actually trigger /application/controllers/subdirectory/ControllerA/someMethod.
Reply
#3

(08-06-2015, 07:15 AM)CroNiX Wrote: With routes.


PHP Code:
$route['someMethodA'] = 'subdirectory/ControllerA/someMethod';
$route['someMethodB'] = 'subdirectory/ControllerB/someMethod'

http://yoursite.com/someMethodA would then actually trigger /application/controllers/subdirectory/ControllerA/someMethod.

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?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB