0

How can I do the following in routes dynamically?

$route['notifications'] = 'admin/notifications';
$route['categories'] = 'admin/categories';

This means that any method name under my controller is the landing page. I don't want the admin controller to appear in the url.

I would simply use $CI->router->method in routes by I can't use get_instance in routes config.

What do I have to do?

Thanks!

ruelluna
  • 787
  • 1
  • 11
  • 30

1 Answers1

0

It's difficult to get dynamic routes since at that point there's not much of CodeIgniter loaded.

I use the following to move all the methods of a controller to the first segment:

$route['(?!(api|account|more))(\w+)/(.*?)'] = "admin/$2/$3";
$route['(?!(api|account|more))(\w+)'] = "admin/$2";

Where api|account|more are routes being ignored.

Woxxy
  • 1,313
  • 10
  • 12