Router and baseUri

Hi everyone!

Here is a new question about router and baseUri application. I set a base uri to /admin/ for my backend module.

If i use :



$this->url->get(array( 'for' => 'myRouteName', 'controller' => 'product', 'action' => 'save' ));

It will add a double /admin/admin/ which is normal because my route is define this way :

$router->add( '/admin/:controller/:action', array( 'module' => 'backend', 'namespace' => 'App\Backend\Controllers\', 'controller' => 1,
'action' => 2, ) )->setName('myRouteName');

The thing is if i remove /admin in my route, it won't still work anymore :)

I guess it's a stupid question but can't find the right solution!


Try to use RouterGroups

//Create a group with a common module and controller
$admin = new RouterGroup(array(
    'controller' => 'index'

//All the routes start with /admin

// now simply add your route
$admin->add( '/:controller/:action', array(
    'module' => 'backend',
    'namespace' => 'App\Backend\Controllers',
    'controller' => 1,
    'action' => 2


Seems to be a good solution, only thing is my routes file contains both frontend and backend routes. Maybe i might be divided my routes in two distinct files.