I am developing an ecommerce website with CI that has product categories and products. I want to route the URL so that it will go to the products controller, then run the getCategoryByName function for the first segment, then run the getProductByName for the second segment. Here is what I have:
URL: products/docupen/rc805
routes.php: $route['products/([a-z]+)'] = "products/getCategoryByName/$1"; $route['products/([a-z]+)/([a-z0-9]+)'] = "products/$1/getProductByName/$2";
But its not working. "docupen" is the category, and "rc805" is the product.
Thanks in advance.
Thank you all for your help. This is what I ended up with for what I needed.
$route['products/:any/:num'] = "products/getProductByID"; $route['products/:any/:any'] = "products/getProductByName"; $route['products/:any'] = "products/getCategoryByName";