|
Few days back I was thinking, if CI could run a specific controller on 404 errors. As we know there is a error template, already present. But what if all the URLs are sent to this error controller…… This controller will check for a specific page in database and get the content for that page. Here's a way to do so: 1. Go to system\libraries\Router.php 2. Go to the following function: _validate_request($segments) initially it is: if (file_exists(APPPATH.'controllers/'.$segments[0].EXT)){ return $segments; } 3. Add elseif condition like this: if (file_exists(APPPATH.'controllers/'.$segments[0].EXT)){ return $segments; }elseif($segments[0]!='admin'){ define('ERROR_PAGE',TRUE,TRUE); $segments[0]='error';//Controller $segments[1]='index';//Function return $segments; } Now on every 404-error page you can run a specific task, even can track the URLs which users have not found and look forward that, how he went there.
|