How to call Controller inside sub folder using codeigniter 3.0?
<p>I have created controller file in sub folder of controller on codeigniter 3.0.</p>

<p>i am using query string formate for url not segment .</p>

<p>i have two type of sub folder for backend(admin) and frontend(user).</p>

<p>i have also created MY_Router file in core folder of application folder.</p>

<p>Structure of Controller</p>

<pre><code>Controller
--backend
   ---admin.php
   ---product.php
--frontend
   ---user.php
</code></pre>

<p>I want url for admin panel:</p>

<pre><code>http://localhost/DemoSite/admin_panel/admin/dashboard
</code></pre>

<p><strong>admin_panel</strong> want it in URL before every backend controller call</p>

<p>admin is Controller<br>
dashboard is Function</p>

<p>For frontend :</p>

<pre><code>http://localhost/DemoSite/user
</code></pre>

<p>I have done route like this :</p>

<pre><code>$route['default_controller'] = 'frontend/user';
$route['admin_panel/(:any)'] = "backend/$1";
$route['(:any)'] = "user/$1";
</code></pre>

<p>MY_Router File Code:</p>

<pre><code>&lt;?php
class MY_Router extends CI_Router {
    protected function _set_default_controller() {

        if (empty($this-&gt;default_controller)) {

            show_error('Unable to determine what should be displayed. A default route has not been specified in the routing file.');
        }
        // Is the method being specified?
        if (sscanf($this-&gt;default_controller, '%[^/]/%s', $class, $method) !== 2) {
            $method = 'index';
        }

        if (is_dir(APPPATH . 'controllers/' . $class)) {
            $this-&gt;set_directory($class);
            $class = $method;
            if (sscanf($method, '%[^/]/%s', $class, $method) !== 2) {
                $method = 'index';
            }
        }

        if (!file_exists(APPPATH . 'controllers/' . $this-&gt;directory . ucfirst($class) . '.php')) {
            return;
        }
        $this-&gt;set_class($class);
        $this-&gt;set_method($method);
        // Assign routed segments, index starting from 1
        $this-&gt;uri-&gt;rsegments = array(
            1 =&gt; $class,
            2 =&gt; $method,
        );
        log_message('debug', 'No URI present. Default controller set.');
    }
}
</code></pre>