We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Help with setting / route

In a multi module application I'm trying to set the / route using:

  $router->add('/', array(
  'module' => 'frontend',
  'namespace' => 'Ammo\Frontend\Modules\Application\Controllers',
  'controller' => 'index',
  'action' => 'someaction'
  ));
$router->notFound(array(
        'module' => 'frontend',
        'namespace' => 'Ammo\Frontend\Modules\Application\Controllers',
        "controller" => "error",
        "action" => "route404"
));

the router seems to ignore this entry for the web site home (no route). I've tried with:

$router = new Router(FALSE); and $router = new Router();

web site root in always fires NotFound route.

Any help??



58.4k
Accepted
answer

Thank you for this. Although using groups did not solve my problem. I'm finding if I set a default module/controller/action and remove the notFound route my main web page is fond (although it is obviously not matching the route->add('/') but using the default route). Also, all notFound routes match to the default module/controller/action defined.

If I add the notFound route, this works great for no routes matched, but also matches to no route https://www.website.com

(

please disregard. var dump of request is showing array(1) { ["_url"]=> string(11) "/index.html" }

it's an apache issue.



32.2k

How did you solve it?