How to create URL like "" www.domain.com/products/blue-shirts "" ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to create URL like "" www.domain.com/products/blue-shirts "" ? (/showthread.php?tid=59928) |
How to create URL like "" www.domain.com/products/blue-shirts "" ? - El Forum - 12-11-2013 [eluser]Kiran K[/eluser] Hi all, I am developing a e-commerce website and i wanted to show url like this "www.domain.com/products/blue-shirts" , how can i achieve this in Codeigniter ?? How can i map the url slug ("blue-shirts") to its unique ID in my product table. ? Please help me. Thanks. Kiran. How to create URL like "" www.domain.com/products/blue-shirts "" ? - El Forum - 12-11-2013 [eluser]CroNiX[/eluser] This should help: http://ellislab.com/codeigniter/user-guide/general/controllers.html#remapping http://ellislab.com/codeigniter/user-guide/general/routing.html How to create URL like "" www.domain.com/products/blue-shirts "" ? - El Forum - 12-11-2013 [eluser]Kiran K[/eluser] I will check that pages. Thanks for your replay. How to create URL like "" www.domain.com/products/blue-shirts "" ? - El Forum - 12-11-2013 [eluser]CroNiX[/eluser] Something like this would probably work /config/routes.php Code: $route['products/(:any)' = 'products/view/$1'; /controllers/products.php Code: class Products extends CI_Controller { How to create URL like "" www.domain.com/products/blue-shirts "" ? - El Forum - 12-11-2013 [eluser]CroNiX[/eluser] Code: $route['products/(:any)' = 'products/view/$1'; Routes with the most segments need to come before those with fewer, like above. First route has 2 segments, "products/some-product" and the 2nd one only has 1, "products". So it should go in that order or the routing won't work properly. |