Hy. I have 2 controllers, the first one application/classes/controller/welcome.php and the second one application/classes/controller/admin/welcome.php.
And I have the following routings, set in bootstrap.php
Route::set('admin', '(<directory>(/<controller>(/<action>(/<id>))))', array('directory' => '(admin)'))
->defaults(array(
'directory' => 'admin',
'controller' => 'welcome',
'action' => 'index',
));
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'welcome',
'action' => 'index',
));
If I access example.com/welcome it calls index action from the application/classes/controller/welcome.php controller (this is good), if I access example.com/admin/welcome it calls index action from application/classes/controller/admin/welcome.php controller (this is good),
but if I access simply example.com, it calls the admin's welcome and not the other one, and I can't understand why.
I want this: if I access example.com, then call index action from application/classes/controller/admin/welcome.php controller. How can I solve this?
It looks like you've set the directory tag in the first route to be optional, and so it's matching when no directory is specified. Try:
Route::set('admin', '<directory>(/<controller>(/<action>(/<id>)))', array('directory' => '(admin)'))
->defaults(array(
'directory' => 'admin',
'controller' => 'welcome',
'action' => 'index',
));
This should make the tag mandatory, and so it won't match on /.
The routes you specify are matched from top to bottom: the first one that matches will be used. So, swap your routes and it should work (make the 'admin' route the last one).