![]() |
Routing errors page - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: Routing errors page (/showthread.php?tid=64368) |
Routing errors page - jpm - 02-13-2016 Hello, First to say : I am new to CI. I want to make a single page for errors 404, 403, ... I created a controller and a view to use this way: http://localhost/error/404 When I enter this adress, the page is displayed correctly. routes.php contains : PHP Code: $route['404_override'] = 'error/show/404'; Then I try to input a wrong address, I have the error : Message: call_user_func_array() expects parameter 1 to be a valid callback, class 'Error' does not have a method 'show/404' I tried to del 'show' in url but same case. Hope someone can point me where I am wrong. JP Error.php (index should be unused) PHP Code: <?php RE: Routing errors page - Narf - 02-13-2016 404_override is rather a configuration setting, not a route. It doesn't translate URI parameters. RE: Routing errors page - jpm - 02-14-2016 (02-13-2016, 08:55 AM)Narf Wrote: 404_override is rather a configuration setting, not a route. It doesn't translate URI parameters. OK thanks. So I managed that in another way. Error.php : PHP Code: <?php in routes.php : $route['404_override'] = 'error'; $route['error/(:num)'] = "error/index/$1"; In .htaccess: ErrorDocument 403 /error/403 This way I may redirect to an error page when I need and leave CI and apache deal with standard errors. JP |