简体   繁体   中英

Problems with Codeigniter HMVC subfolders

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM