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.
you might want to use this simple trick. Just change the code below:
<?php echo base_url() ?>
to:
<?php echo config_item(‘base_url’); ?>
credit for https://www.petanikode.com/codeigniter-base-url-404/ this work for my case
Try following in application/errors/error_404.php
$CI =& get_instance();
if( ! isset($CI))
{
$CI = new CI_Controller();
}
$CI->load->helper('url');
echo $CI->base_url();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With