![]() |
wildcard routes - 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: wildcard routes (/showthread.php?tid=27293) |
wildcard routes - El Forum - 02-06-2010 [eluser]richzilla[/eluser] Hi all, I've looked through the user guide, but it doesn't seem to make what i want to do very clear, or I'm missing something... Basically i want to route a url with any function name to the same controller, but with the function name appended to the end. so for example in my site: id want Code: /health-and-safety/courses Code: /hs/courses Code: health-and-safety/home Code: hs/home I can do it on the routes side of the statement with Code: /health-and-safety/:any Code: :any Any help would be appreciated. Thanks wildcard routes - El Forum - 02-06-2010 [eluser]Kosonome[/eluser] You change the route /health-and-safety/home -> /hs/index/home, then you can make one more route /hs/index/home -> /hs/home. Or you can make a regular expression. I guess that's the best way, since it gives me headaches (I'm not good with them yet ![]() wildcard routes - El Forum - 02-06-2010 [eluser]richzilla[/eluser] Thanks for the help. Yea, i thought about doing that, but the health and safety section might have 20 pages eventually, so im trying to avoid hard coding routes for every page, what i want is for it to basically replace the Code: health-and-safety/ Code: hs/ wildcard routes - El Forum - 02-07-2010 [eluser]tomcode[/eluser] Put these two lines in Your config/routes.php : Code: $route['health-and-safety'] = 'hs'; Now all requests for health-and-safety end in the controller hs. |