In codeigniter, normally the routing is in the manner "host.com/controller/method/id" means, typically there is a one-to-one relationship between a URL string and its corresponding controller class/method.
But some time developer or client want to remap this relationship. for example,
"host.com/user/3".
In codeigniter, routing rules are defined in your application/config/routes.php file. If you want to create your own routing rule then you should need to write the rule in this file in an an array called $route, that permits you to specify your own routing criteria. Routes can either be specified using wildcards or Regular Expressions.
A typical wildcard route might look something like this:
$route['product/:num'] = "catalog/product_lookup";
which is,
$route['product/:num'] = "controller name/ method name";
If the url -"host.com/product/2" hitted then the app the "product_lookup" method from "catalog" controler.
0 Comment(s)