[RESOLVED] 'default_controller' vs 'controller in sub-directory' |
![]() (This post was last modified: 01-20-2016, 04:52 AM by cloud_live. Edit Reason: Problem is resolved. )
Hi All,
I have some question to ask. I have a controller inside a sub-directory. To be more specific. I have a controller name 'Main' (Main.php) in sub-directory 'Report' so the path to this controller will be 'controllers/Report/Main.php'. I can access to the controller by typing the url like 'mywebsite.com/Report/Main'. The page displays correctly. Now I want to config the 'default_controller' to point to this controller when visitor type 'mywebsite.com' or 'mywebsite.com/index.php'. I opened 'config/routes.php' and changed $route['default_controller'] to 'Report/Main/'. I saved and closed. I tried 'mywebsite.com/index.php'. The webpage show me '404' error. I tried to enter the url manually. The target page is displayed correctly. I thought the controller named 'Main' might be reserved word. So I changed 'Report/Main.php' to 'Report/MainPage.php' and I also changed the controller name inside the file. Then I changed $route['default_controller'] to 'Report/MainPage/'. Still '404' error. Any advice would be appreciated. Thank you so much in advance. Have a nice day everyone ![]() With Best Regards, Chatawat
According to http://codeigniter.com/user_guide/general/routing.html, you can't use a directory/controller combination as the default route configuration.
Best regards,
José Postiga Senior Backend Developer
Oh ... my bad.
what about $route ? what if I set 'default_controller' to 'Main' (It will be located at 'controllers/Main.php') then I'll set $route['Main'] = 'Report/Main' ? thank you so much for your reply ![]()
(01-20-2016, 04:24 AM)josepostiga Wrote: According to http://codeigniter.com/user_guide/general/routing.html, you can't use a directory/controller combination as the default route configuration. Thank you so much for your answer. Now I got answer for myself. I put 'Main.php' as 'controller/Main.php' and set $route['default_controller'] = 'Main' then I set the redirect to the url I want. Now you may close this thread ![]() With Best Regards, Chatawat |
Welcome Guest, Not a member yet? Register Sign In |