title: How do you use multiple controllers in CodeIgniter?
body: <p>I'm new to CodeIgniter and I've just gone through some of their user guide to help me understand how to do multiple controllers.</p>
  
  <p>I have figured out how to load multiple pages using one of their examples. This is my default controller, called Site.php:</p>
  
  <pre><code>class Site extends CI_Controller {
  
  public function index($page = 'home') {
      if ( ! file_exists(APPPATH.'/views/'.$page.'.php')) {
          // Whoops, we don't have a page for that!
          show_404();
      }
  
      $data['title'] = ucfirst($page);
  
      $this-&gt;load-&gt;view('header', $data);
      $this-&gt;load-&gt;view($page, $data);
      $this-&gt;load-&gt;view('footer', $data);
  
      }
  }
  </code></pre>
  
  <p>This all works well and good with my routes.php:</p>
  
  <pre><code>$route['default_controller'] = 'site';
  $route['(:any)'] = 'site/index/$1';
  </code></pre>
  
  <p>I have a few views that do load correctly when I go to <code>localhost/website/index.php/about</code>, for example.</p>
  
  <hr>
  
  <p>Now, to further learn about controllers and URI routing. I created a new controller, <code>application/controllers/MyController.php</code> and it is coded as such:</p>
  
  <pre><code>class MyController extends CI_Controller {
      public function index() {
          $this-&gt;load-&gt;view('header');
          $this-&gt;load-&gt;view('my_controller');
          $this-&gt;load-&gt;view('footer');
      }
  }
  </code></pre>
  
  <p>The thing is, I don't know how to access this page.
  I understand that the default URI pattern is <code>example.com/class/function/id/</code> but I have tried <code>localhost/website/mycontroller</code> and it doesn't work. Apache returns 404. I've tried many manipulations of this, even going as stupid as typing <code>localhost/website/index.php/mycontroller</code> but of course that doesn't work.</p>
  
  <p><br/>
  <strong>What is the correct way to use multiple controllers? What have I done wrong here? Please assist me in my learning, thank you!</strong></p>
  
  <p><sub>(Also, this is my first proper question on StackOverflow, if I've done anything wrong or formatted something incorrectly, please let me know!)</sub></p>