Help with route regex if specific words are present - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Help with route regex if specific words are present (/showthread.php?tid=37560) |
Help with route regex if specific words are present - El Forum - 01-13-2011 [eluser]CroNiX[/eluser] I have a few custom pages like site.com/about site.com/help site.com/privacy Currently they are going to their own controllers. I want to create a generic controller that will handle these specific pages but leave the rest of the routing alone. I think this is close but can't quite get it. I'm a regex idiot...and I admit it. Code: $route['((?about|help|home|privacy|tou).*)'] = 'custom_page/$1'; Thanks for any help. Help with route regex if specific words are present - El Forum - 01-13-2011 [eluser]Cristian Gilè[/eluser] You could put a _remap() in your base controller. Cristian Gilè Help with route regex if specific words are present - El Forum - 01-13-2011 [eluser]CroNiX[/eluser] Thanks. I'm not using a single base controller. If the url is a certain word, I want to map it to a specific controller and leave the rest alone. Basically a one liner for: $route['about'] = 'custom_page/about'; $route['home'] = 'custom_page/home'; $route['help'] = 'custom_page/help'; ... $route['(.*)/communities/(.*)'] = 'locations/view_community/$1/$2'; ... more routes... Help with route regex if specific words are present - El Forum - 01-18-2011 [eluser]Imran Tariq[/eluser] Instead of using this [quote author="CroNiX" date="1294967168"] $route['about'] = 'custom_page/about'; $route['home'] = 'custom_page/home'; $route['help'] = 'custom_page/help';[/quote] You should try this Quote:$route['about|home|help'] = 'custom_page/$1'; |