0
votes

I have encountered an issue using subfolders with Codeigniter + HMVC.

/system/application/modules/welcome/controllers/staff/welcome.php

To access this I have to access it via http://www.app.com/welcome/staff/welcome

Unfortunately this doesn't fit the rest of my URL structure.

How can I remove the first welcome from the URL so the URL is http://www.app.com/staff/welcome

I have tried adding a route within the module:

/system/application/modules/welcome/config/routes.php

like:

$route['staff/welcome'] = "welcome/staff/welcome";

but unfortunately no luck.

Adding this route to the real codeigniter route file works but I feel that adding code external of the modules to get modules to work misses the point of adopting modularisation.

I hope someone is able to help.

Thanks,

Tim

1
Were you ever able to get module-specific /config/routes.php to work properly? If so, would you mind sharing how?ServAce85

1 Answers

1
votes

This line in your routes.php is correct:

$route['staff/welcome'] = "welcome/staff/welcome";

You can try to play with the order of your routing rules, and to put the rule for the default controller ($route['default_controller'] = "home";) at the end. I have project with 4 modules and it works fine for me.