Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

NotFound on Router groups

Hi, I have a Router\Group that has a different domain, php $group->setHostName('');

how can I create a different 404 page for this specific group ? php $router->notFound(...) will work only for the main domain.

Thank you.


notFound() unavailable for Phalcon\Mvc\Router\Group.

You must create handler in notFound method where you can catch all 404 requests and call needful controller. Something like

$app->notFound( function () use ($app) {
         if($app->getHostName == '') {
            $my404 = new \App\Controllers\sub404Controller;
            $my404 = new \App\Controllers\main404Controller;
         return $my404;