title: How to redirect from hook to another controller
body: <p>I want redirect user in login page if is not logged</p>
  
  <p>my hook HK_Login.php inside application/hooks</p>
  
  <pre><code>&lt;?php
  
      class HK_Login
      {
          private $CI;
          public function checkLogin()
          {
              $this-&gt;CI =&amp; get_instance();
              if($this-&gt;CI-&gt;session-&gt;userdata('ID') == '' &amp;&amp; $this-&gt;CI-&gt;uri-&gt;segment(3) != 'login' )
              {
                  redirect($this-&gt;CI-&gt;uri-&gt;segment(1) . '/secure/login');
              }
  
          }
      }
  </code></pre>
  
  <p>my controller Secure.php inside application/controllers</p>
  
  <pre><code>&lt;?php
  class Secure extends CI_Controller
  {
      public function __construct()
      {
          parent::__construct();
      }
  
      public function login()
      {
          $this-&gt;load-&gt;view('login/index');
      }
  }
  </code></pre>
  
  <p>The result is :</p>
  
  <pre><code>Not Found
  
  The requested URL /web/secure/login was not found on this server.
  </code></pre>
  
  <p>My .htaccess</p>
  
  <pre><code>DirectoryIndex index.php
  RewriteEngine on
  RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
  </code></pre>
  
  <p>A part of my config.php</p>
  
  <pre><code>$config['index_page'] = '';
  $config['uri_protocol'] = 'REQUEST_URI';
  $config['enable_hooks'] = TRUE;
  </code></pre>
  
  <p>autoload</p>
  
  <pre><code>$autoload['helper'] = array('url', 'custom');
  $autoload['libraries'] = array('database', 'session');
  </code></pre>
  
  <p>hook config</p>
  
  <pre><code>$hook['post_controller_constructor'][] = array(
      'class' =&gt; 'HK_Login',
      'function' =&gt; 'checkLogin',
      'filename' =&gt; 'HK_Login.php',
      'filepath' =&gt; 'hooks'
  );
  </code></pre>
  
  <p>This is my routes.php</p>
  
  <pre><code>$route['default_controller'] = 'dashboard';
  $route['404_override'] = '';
  $route['translate_uri_dashes'] = FALSE;
  </code></pre>
  
  <p>Why give me this error?</p>
  
  <p>added in routes.php </p>
  
  <pre><code>$route['/secure/login'] = 'secure/login';
  </code></pre>
  
  <p>Give the same error</p>