Welcome Guest, Not a member yet? Register   Sign In
Custom 404 control
#6

[eluser]DieterStruik[/eluser]
Hmmm... for better understanding it's better to clean things up in clear steps.

STEP 1: routes.php
Code:
$route['default_controller'] = 'firstcontroller';
$route['scaffolding_trigger'] = '';

// When first segment is set proceed normally (language checking done in controller)
$route['(\w{2})/(.+)'] = '$2';

// Catch all (important for 404 and language checking)
$route[':any'] = $route['default_controller'];

STEP 2: The extended controller or method in every controller
Code:
public function error404()
{
    // Get all arguments passed.  
    $args = func_get_args();

    // This view shows the $uri string after the /en/firstcontroller/error404
    $this->load->view('error404', array(            
        'uri' => join('/', $args)
    ));    
}

STEP 3: Replace contents of the error_404.php
Code:
<?php
// Display custom 404 from existing method.
echo file_get_contents('http://'.$_SERVER['SERVER_NAME'].'/en/firstcontroller/error404/'.$_SERVER['REQUEST_URI']);
?>
// Will get page form:
// 'http://www.yoursite.com/en/firstcontroller/error404/wrong/url/segments/like/these'


Messages In This Thread
Custom 404 control - by El Forum - 01-15-2010, 06:28 AM
Custom 404 control - by El Forum - 01-15-2010, 07:01 AM
Custom 404 control - by El Forum - 01-15-2010, 07:08 AM
Custom 404 control - by El Forum - 01-15-2010, 08:23 AM
Custom 404 control - by El Forum - 01-15-2010, 08:25 AM
Custom 404 control - by El Forum - 01-15-2010, 08:35 AM
Custom 404 control - by El Forum - 01-15-2010, 09:11 AM
Custom 404 control - by El Forum - 05-18-2010, 08:37 AM
Custom 404 control - by El Forum - 06-16-2010, 01:08 PM
Custom 404 control - by El Forum - 06-16-2010, 02:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB