DN0300
DN0300

Reputation: 876

CakePHP Homepage URL Redirect

My website is using CakePHP and homepage URL gets redirected and looks like this

domain.com/pages/home

I want to prevent the redirect load index file at domain.com I can't figure out how to load index without redirecting.

This is what I have right now.

    if(!$this->Auth->loggedIn()){
        return $this->redirect('/pages/home');
    }

Upvotes: 1

Views: 3183

Answers (1)

Ravinder Reddy
Ravinder Reddy

Reputation: 3879

Check in routes.php file if you have this line of code (if not add it).

Router::connect('/', array('controller' => 'pages', 'action' => 'home')); 

and this in the controller

if(!$this->Auth->loggedIn()){ 

    $this->redirect('/');
    //or
    //$this->redirect(array('controller' => 'pages', 'action' => 'home'));

}

Upvotes: 5

Related Questions