Routing is a feature that maps URLs to controller actions.
It was added to CakePHP to make pretty URLs more configurable and flexible. Using Apache’s mod_rewrite is not required for using routes, but it will make your address bar look much more tidy.
Routes in an application are configured in app/Config/routes.php
.
Example:
Router::connect(
'/pages/*',
array('controller' => 'pages', 'action' => 'display')
);
This route is found in the routes.php
file distributed with CakePHP. This route matches any URL starting with /pages/
and hands it to the display()
action of the PagesController();
The request /pages/products
would be mapped to PagesController->display('products')
.