CodeIgniter Forums
Routing 2 similar url pattern on different controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Routing 2 similar url pattern on different controller (/showthread.php?tid=65303)



Routing 2 similar url pattern on different controller - groovebird - 05-26-2016

Hi,

i have two groups of urls which should be routed on 2 different controllers. the problem is, they have the same pattern.

Example: new-products and our-products. this is the same pattern [:any]-products, but could this be routed to differnt controllers without hardcoding in the routes.php?


RE: Routing 2 similar url pattern on different controller - skunkbad - 05-26-2016

You should think about having a single products controller, and then using mod_rewrite to rewrite new-products to /products/new and our-products to /products/ours. If the products are coming from different resources, then you'd have more than one product oriented model, pulling in products when you call for them.