user_guide_src/source/installation/upgrade_routing.rst
Upgrade Routing ##################
.. contents:: :local: :depth: 2
URI Routing Documentation CodeIgniter 3.x <http://codeigniter.com/userguide3/general/routing.html>_URI Routing Documentation CodeIgniter 4.x </incoming/routing>auto-routing-improved is introduced.(:any) In CI3 will be the Placeholder (:segment) in CI4. The (:any) in CI4 matches multiple segements. See :ref:URI Routing <routing-placeholder-any>.If you use the Auto Routing in the same way as CI3, you need to enable :ref:auto-routing-legacy.
You have to change the syntax of each routing line and append it in app/Config/Routes.php. For example:
$route['journals'] = 'blogs'; to $routes->add('journals', 'Blogs::index');. This would map to the index() method in the Blogs controller.$route['product/(:any)'] = 'catalog/product_lookup'; to $routes->add('product/(:segment)', 'Catalog::productLookup');. Don't forget to replace (:any) with (:segment).$route['login/(.+)'] = 'auth/login/$1'; to $routes->add('login/(.+)', 'Auth::login/$1');.. note:: For backward compatibility, $routes->add() is used here. But we
strongly recommend to use :ref:routing-http-verb-routes like
$routes->get() instead of $routes->add() for security.
Path: application/config/routes.php:
.. literalinclude:: upgrade_routing/ci3sample/001.php
Path: app/Config/Routes.php:
.. literalinclude:: upgrade_routing/001.php
.. note:: For backward compatibility, $routes->add() is used here. But we
strongly recommend to use :ref:routing-http-verb-routes like
$routes->get() instead of $routes->add() for security.