2015-07-02 63 views
0

CakePhp 2在Web Hosting上重定向循環。但它在本地計算機上工作。有沒有人可以解決我的問題?Cakephp 2身份驗證重定向循環

這是我的AppController

class AppController extends Controller { 

public $components = array(
    'Acl', 
    'Auth' => array(
     'authorize' => array(
      'Actions' => array('actionPath' => 'controllers') 
     ), 
     'authenticate' => array(
      'Form' => array(
       'scope' => array('User.status' => '1') 
      ), 
     ), 
    ), 
    'Session', 
    'DebugKit.Toolbar', 
); 

public $helpers = array('Html', 'Form', 'Session'); 

public $uses = array(
    'Configuration.Configuration', 
    'EmailTemplate.EmailTemplate', 
); 


public $theme = ""; 


public function beforeFilter() { 

    //Configure AuthComponent 
    $this->Configuration->load(); 
    $this->Auth->loginAction = array(
     'controller' => 'users', 
     'action' => 'login', 
     'plugin' => false 
    ); 
    $this->Auth->logoutRedirect = array(
     'controller' => 'users', 
     'action' => 'login', 
     'plugin' => false 
    ); 
    $this->Auth->loginRedirect = array(
     'controller' => 'users', 
     'action' => 'dashboard', 
     'plugin' => false 
    ); 

    $this->check_group(); 
    ####### Define Plugin layout ####### 
     if($this->params['plugin']=='content') 
     $this->layout = 'content'; 

} 

private function check_group() 
{ 
    $this->theme = 'CakeReady'; 

    if (isset($this->request->params['admin'])) { 
     $this->layout = 'admin'; 
    } 

    if ($this->params['plugin'] == 'acl') { 
     $this->layout = 'acl'; 
    } 

    if ($this->request->is('ajax')) { 
     $this->layout = 'ajax'; 
    } 

    if(!isset($this->request->params['admin']) && Configure::read('Site.coming_soon') == 1){ 
     $this->theme = 'CakeReady'; 
     $this->layout = 'coming_soon'; 
     $this->set('title_for_layout', __('Coming Soon')); 
    } 
    else if (!isset($this->request->params['admin']) && Configure::read('Site.status') == 0){ 
     $this->theme = 'CakeReady'; 
     $this->layout = 'maintenance'; 
     $this->set('title_for_layout', __('Site down for maintenance')); 
    } 
    else if (!isset($this->request->params['admin'])){ 
     $this->theme = 'CakeReady'; 
     $this->layout = 'coming_soon'; 
     $this->set('title_for_layout', __('Coming Soon')); 
    } 

} 

而其我UsersController

class UsersController extends AppController { 

/** * 組件 * * @var陣列 */

public $components = array('Paginator','Qimage'); 

public function beforeFilter() { 
    parent::beforeFilter(); 
    $this->Auth->allow('admin_forget_password', 'login', 'admin_login','subscriber','activate_code', 'register', 'captcha'); 
} 

public function login() { 
    $show_action = 'login'; 
    $this->layout = 'admin_login'; 
    if ($this->request->is('post')) { 
     if ($this->Auth->login()) { 
      $this->Session->setFlash(__('Congratulation You are login succcessfully.'), 'success'); 
      return $this->redirect($this->Auth->redirect()); 
     } 
     $this->Session->setFlash(__('<h4>Your username or password was incorrect.</h4>'), 'errorText'); 
    } 
    $this->set(compact('show_action')); 
} 

/** * admin_login方法 * * @返回無效 */

public function admin_login() { 
    $show_action = 'login'; 
    $this->layout = 'admin_login'; 
    if ($this->request->is('post')) { 
     if ($this->Auth->login()) { 
      $this->Session->setFlash(__('Congratulation You are login succcessfully.'), 'success'); 
      return $this->redirect($this->Auth->redirect()); 
     } 
     $this->Session->setFlash(__('<h4>Your username or password was incorrect.</h4>'), 'errorText'); 
    } 
    $this->set(compact('show_action')); 
} 

回答

0

是啓用了mod_rewrite?

你也有這個嗎?

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteRule ^$ webroot/ [L] 
    RewriteRule (.*) webroot/$1 [L] 
</IfModule> 
+0

無法正常工作..感謝您的回覆 –