I would like to create a custom CMS in Codeigniter, and I need a mechanism to route shared pages to the default controller - for example:
mydomain.com/about
mydomain.com/services/maintenance
They will be routed through my controller-manipulator. By default, the routing behavior in Codeigniter, of course, is directed to the appropriate controller and method, so in the above examples, this requires the About controller and the services controller. This is obviously not a practical or even sensible approach.
I saw the following solution for hosting in routes.php:
$route['^(?!admin|products).*'] = "pagehandler/$0";
But this creates my own problems, which I believe in. For example, it just searches for “products” in the uri request and finds the routes to the Products controller - but what if we have services / products as a CMS page? Is this then directed to the product controller?
Is there an ideal approach to this? I do not want to have routing where all the content of the CMS has a controller name prefix, but I should also be able to redefine the routing for other controllers altogether.
source
share