Search code examples
phpcakephpurl-routingcakephp-3.x

What is CakePHP 3 home page? I can't redirect to that


I am developing a web page in CakePHP 3 and I have a problem.

I have the view for the home page in "src/Template/Pages/home.ctp" and I create this function in the PagesController.php

public function home() 
{ //code...
}

I can enter to this page if I go to URL: http://example.com/Pages/home but if I go to http://example.com/ I not go to this page. And if I go to http://example.com/pages/home neither.

What is my mistake? I don't see it! I want to edit the "real" home page where I can go when I go to http://example.com


Solution

  • In config folder in routes.php file:-

    Change this

    $routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
    

    To

    $routes->connect('/', ['controller' => 'Pages', 'action' => 'home']);