In CakePHP 3.x I am trying to set correct routing from the old page with the old slug into the new page with the new slug. The old page is removed and should redirect to new page. How should I correct the routing:
$routes->connect('/controllerName/actionName/old-slug',
['controller'=>'controllerName','action'=>'actionName','slug'=>'new-slug']);
That's what redirect routes are there for:
$routes->redirect(
'/controllerName/actionName/old-slug', // old
['controller' => 'controllerName', 'action' => 'actionName', 'slug' => 'new-slug'], // new
['status' => 301] // options
);
For better performance I would suggest to redirect at server level instead.
See also