Cake 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方法 * * @return void * /
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 :(得分:0)
是否启用了mod_rewrite?
你也有这个吗?
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>