CodeIgniter access base_url() inside error_404.php

Viewed 6916

When 404 Page Not Found error occurs application/errors/error_404.php template is used in CodeIgniter. I need to access the base_url() function inside that template. Any suggestion on how base_url() or site_url() functions can be accessed inside error_404.php will be really helpful.

9 Answers

Edit your /application/config/routes.php

$route['404_override'] = 'your_controller/error';

Add function into your_controller.php

function error(){
    show_404();   
}

You are ready to go.

this work for my case, try this method

Change the function base_url() to config_item('base_url')

    <?php echo config_item('base_url'); ?>
Related