Custom CodeIgniter route regex -
trying improve custom codeigniter route regex have created. purpose of custom route create cleaner/shorter url client profile pages have format of clients/client-slug
, example: clients/acme-inc
. want route match if no additional segments after client-slug segment, , if client-slug value not match of 'reserved' values correspond actual methods/routes in clients controller. currently, i'm using:
$route['clients/(?!some_method|another_method|foo|bar)(.+)'] = 'clients/index/$1';
this works ok, except when there client-slug begins 1 of reserved methods text, i.e. clients/food-co
, since has clients/foo
in it, custom route not matched. need conditionally allow route contain of reserved methods in set if followed additional characters (that not /
).
do try this?
$route['clients/(?!(?:some_method|another_method|foo|bar)(?:/|$))(.+)'] = 'clients/index/$1';
Comments
Post a Comment