title: Not able to redirect page in CAKE PHP
body: <p>When i follow <code>$this-&gt;Auth-&gt;allow('login');</code> this approach, we are not able to redirect to dashboard page. If i follow <code>$this-&gt;Auth-&gt;allow();</code> this approach we are able to redirect to dashboard page.</p>
  
  <p>But i need to use first approach for login.</p>
  
  <p>I have a AppController.php which is performed Login Action.</p>
  
  <p>Below is the AppController.php Code</p>
  
  <pre><code>function beforeFilter() {
  
      Security::setHash('md5');
  
      // Authenticate
      $this-&gt;Auth-&gt;authorize = 'Controller';
      $this-&gt;Auth-&gt;autoRedirect = false;
      $subdomain = substr( env("HTTP_HOST"), 0, strpos(env("HTTP_HOST"), ".") );
  
  
      if($this-&gt;params['controller']=="moderator")
      {
  
          //$this-&gt;Auth-&gt;allow(); // if i use this one my code is working fine.
          $this-&gt;Auth-&gt;allow('login');            
  
          $this-&gt;Auth-&gt;loginAction = array('controller' =&gt; 'moderator', 'action' =&gt; 'login');
          $this-&gt;Auth-&gt;loginRedirect = array('controller' =&gt; 'moderator', 'action' =&gt; 'dashboard');
          $this-&gt;Auth-&gt;loginError = 'No username and password was found with that combination.';
          $this-&gt;Auth-&gt;logoutRedirect = array('controller' =&gt; 'moderator', 'action' =&gt; 'login');
          AuthComponent::$sessionKey = 'Auth.Admin';
      }
  
  }
  </code></pre>
  
  <p>when we are login the page it will goto ModeratorController.php controller page and then check the usename and password using <strong>Auth</strong> , if username &amp; password correct it will <strong>call</strong> the <strong>dashboard</strong> function.</p>
  
  <p>Below is the ModeratorController.php Code</p>
  
  <pre><code>class ModeratorController extends AppController {
  
  public $components = array('RequestHandler','Session',
          'Auth'=&gt;array(
                  'authenticate' =&gt; array(
                          'Form' =&gt; array(
                                  'fields'=&gt;array(
                                          'username'=&gt;'username',
                                          'password'=&gt;'password'
                                  ),
                                  'userModel'=&gt; 'Admin'
                          ),
                  ),
                  'loginAction' =&gt;array(
                          'Controller' =&gt; 'moderator',
                          'action' =&gt; 'login'
                  ),
                  'loginRedirect'=&gt;array('Controller'=&gt;'moderator', 'action'=&gt;'index'),
                  'logoutRedirect'=&gt;array('Controller'=&gt;'moderator', 'action'=&gt;'index'),
                  'authError'=&gt;"You can't access that page",
                  'authorize'=&gt;'Controller',
                  'loginError'=&gt; 'Login error',
  
  
          )
  );
  public $helpers = array('Js' =&gt; array('Jquery'),'Html','Paginator');
  
  
      function beforeFilter() {
          //used version cake 2.3.0.
  
          parent::beforeFilter();
  
      }
  
  
      // for moderator login process
  
      public function login() {
  
          if($this-&gt;Session-&gt;read('Auth.Admin.admin_id'))
          {           
               $this-&gt;redirect('dashboard');
          }
  
          if($this-&gt;request-&gt;data)
          {
  
           $this-&gt;Admin-&gt;set($this-&gt;data);
           if($this-&gt;Admin-&gt;validates())
           {
              if($this-&gt;Auth-&gt;login()){
  
  
                  //$this-&gt;redirect('/moderator/dashboard');  // result: redirect to moderator/login              
                  //$this-&gt;redirect(array('controller' =&gt; 'moderator', 'action' =&gt; 'dashboard')); // result: redirect to moderator/login
                  //$this-&gt;redirect($this-&gt;Auth-&gt;redirect()); // result: redirect to moderator/login
                  //$this-&gt;redirect(array('action' =&gt; 'dashboard')) // result: redirect to moderator/login
                  //$this-&gt;redirect('dashboard12'); // result: redirect to moderator/dashboard12 and give me 404. That result is correct
                  //$this-&gt;redirect('/dashboard'); // result: redirect to /dashboard and give me 404. That result is also correct
                  $this-&gt;redirect('dashboard')) // result: redirect to moderator/login
              }
              else
              {
                  $this-&gt;Session-&gt;setFlash(__('Invalid email or password, try again'));
              }
          }
       }
  
  
      }
  
  
      public function dashboard()
      {
          echo "I am in dashboard";
          exit();
      }
  }
  </code></pre>
  
  <p>Thanks</p>