我的网站是使用CakePHP和主页网址被重定向,看起来像这样CakePHP的主页URL重定向
domain.com/pages/home
我想防止domain.com
重定向负载索引文件我无法弄清楚如何在不加载索引重定向。
这就是我现在所拥有的。
if(!$this->Auth->loggedIn()){
return $this->redirect('/pages/home');
}
我的网站是使用CakePHP和主页网址被重定向,看起来像这样CakePHP的主页URL重定向
domain.com/pages/home
我想防止domain.com
重定向负载索引文件我无法弄清楚如何在不加载索引重定向。
这就是我现在所拥有的。
if(!$this->Auth->loggedIn()){
return $this->redirect('/pages/home');
}
如果您有这行代码(如果没有添加它),请检查routes.php文件。
Router::connect('/', array('controller' => 'pages', 'action' => 'home'));
,这在控制器
if(!$this->Auth->loggedIn()){
$this->redirect('/');
//or
//$this->redirect(array('controller' => 'pages', 'action' => 'home'));
}
你说的是路由? https://book.cakephp.org/3.0/en/development/routing.html –
我尝试过路由,但是我无法使它工作。如果(!$ this-> Auth-1)在路由器上连接('/',array('controller'=>'pages','action'=>'home')) > loggedIn()){ \t \t \t $ this-> home(); \t \t}' – DN0300