I have run into an issue with routing of the admin and fronted pages of my module. Below is the code I have,

// public
$route['work(/:num)?'] = 'work/index$1';
$route['work(/:any)?'] = 'work/project$1';
// admin
$route['work/admin/clients(:any)?'] = 'admin_clients$1';
$route['work/admin/projtypes(:any)?'] = 'admin_projtypes$1';
$route['work/admin/roles(:any)?'] = 'admin_roles$1';
$route['work/admin/agency(:any)?'] = 'admin_agency$1';

The two lines for the public routing work great, they allow me to list all the items in the database on a list page and then using a slug let me display all elements pertaining to each item on a separate page. It also allows me to use the pagination helper to show 5 items per listing page.
The downside of this is that this line,

$route['work(/:any)?'] = 'work/project$1';

breaks the admin panel and doesn't allow me to view any of the admin pages in the module. It displays a page using the frontend template and throws up a load of errors.
Is it the (/:any)? on the line that is overriding the other routes, when I comment out the line the admin is accessible. Would I have to add in some kind of ID before each slug name to make it more unique.
All feedback appreciated.


  • Quick suggestion, try moving the admin routes above the public ones.
  • Tried that already with no effect unfortunately.
  • I've lost several hours on this same problem! The issue seems to be using (:any) in the public routes breaks the admin ones (or overrides them at least). I fixed my problem by using more specific regex for the public routes:
    $route['example/([a-z0-9-]+)'] = 'example/view/$1';
    Hope that helps!
  • That worked perfectly, cheers mate its hugely appreciated.
  • Hi, I have a similar problem, this one doesn't work (pyrocms 2.1.5): $route['example/([a-z0-9-]+)/([a-z0-9-]+)'] = 'example/view/$1/$2'; - it breaks the admin module, but this one does: $route['example/([a-z0-9-]+)/my-method'] = 'example/view/$1/my-method';; Does somebody have a suggestion why?

You must sign in to comment.