Question: How to run controller from the sub folder in codeigniter.

I have tried but i get the following error bellow.

[![enter image description here](https://i.stack.imgur.com/wruhe.png)](https://i.stack.imgur.com/wruhe.png)

Answer: 
You can do this by following below steps:

Stpep 1) create sub-folder `"superadmin"` in controllers folder like below:

```
controllers/superadmin

```

Stpep 2) create controller `controllers/superadmin/loginvalueget.php` in sub-folder `"superadmin"` like below:

```
<?php

class Loginvalueget extends CI_Controller {

    function index()
    { 
        die('hello world');     
    }

}

?>

```

Step 3) change default controller route in `application/config/routes.php` like below:

```
$route['default_controller'] = 'superadmin/loginvalueget';

```

Step 4) replace \_set\_default\_controller() with below method in `system/core/Router.php`:

```
protected function _set_default_controller()
    {
        if (empty($this->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?
        $x = explode('/', $this->default_controller);
        $dir = APPPATH.'controllers';
        $dir_arr = array();
        foreach($x as $key => $val){            
            if(!is_dir($dir.'/'.$val)){
                if(file_exists($dir.'/'.ucfirst($val).'.php')){
                    $class = $val;
                    if(array_key_exists(($key+1), $x)){
                        $method = $x[$key+1];
                    }else{
                        $method = 'index';
                    }
                }else{
                    show_error('Not found specified default controller : '. $this->default_controller);
                }                
                break;               
            }
            $dir_arr[] = $val;
            $dir = $dir.'/'.$val;
        }
        //set directory
        $this->set_directory(implode('/', $dir_arr));

        $this->set_class($class);
        $this->set_method($method);

        // Assign routed segments, index starting from 1
        $this->uri->rsegments = array(
            1 => $class,
            2 => $method
        );

        log_message('debug', 'No URI present. Default controller set.');
    }

```
As you can see yourself in the attachment, you haven't set the route. You can do this by setting route path in "application>config>routes.php".