CodeIgniter Forums
404_override controller cannot be in subfolder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: 404_override controller cannot be in subfolder (/showthread.php?tid=48488)



404_override controller cannot be in subfolder - El Forum - 01-18-2012

[eluser]sehummel[/eluser]
I spent three days banging my head against the wall trying to figure out why my 404 page would not load when there was no controller for that route. What it finally came down to was that for this route:

Code:
$route['404_override'] = "misc/route_map";
(folder/controller)

CI was reading misc as the controller name. When I moved route_map to the root controllers folder, everything worked right. You should be able to place a 404_override controller in a subfolder. This contradicts what is written in the routes.php file. The folder/controller mapping works perfectly in the rest of the site.

I am running version 2.1 of CI and have properly upgraded from 2.02.


404_override controller cannot be in subfolder - El Forum - 01-18-2012

[eluser]CroNiX[/eluser]
So, I assume your index method is what you are actually using to handle the 404? I believe it is expecting a "controller/method" like everything else in CI. The example in config.php shows a controller/method.

Did you happen to try
Code:
$route['404_override'] = "misc/route_map/index";
? Maybe it will treat the first segment as a folder then if there are more than 2. Don't know, haven't tried...


404_override controller cannot be in subfolder - El Forum - 01-18-2012

[eluser]sehummel[/eluser]
I tried that and it didn't work.


404_override controller cannot be in subfolder - El Forum - 01-18-2012

[eluser]Matt S.[/eluser]
Looks like you can't have the override in a sub-folder. I just pulled this snippet out of CodeIgniter.php and it's hard coded to use the first segment as the class and second as the method:

Code:
$x = explode('/', $RTR->routes['404_override']);
$class = $x[0];
$method = (isset($x[1]) ? $x[1] : 'index');