I want to have nice good looking error pages. For this I need to get some CSS and JS files. But for some odd reason using base_url()
does not work on the error_pages. I could of course just use href="/css/style.css"
and tell it to get it from the root folder. But the website could very well be put in a different folder than the root folder. So using the /
is not an option.
So my question now is why doesn't base_url()
work on an error page? I have autoloaded it so shouldn't it be working?
This is what I tried when I was trying to get the base_url() from the error_404 page in the view.
In my autoload.php I have included the helper url
$autoload['helper'] = array('url', 'form');
And in my error_404 page (application/views/errors/html/error_404.php) I am echoing the base_url like so:
<?php echo base_url(); ?>
This is the error I'm getting:
An uncaught Exception was encountered
Type: Error
Message: Call to undefined function base_url()
Filename: /usr/local/www/example.com/application/views/errors/html/error_404.php
Line Number: 37
Backtrace:
File: /usr/local/www/example.com/index.php
Line: 315
Function: require_once
I'd rather not make any changes in the system
folder since I don't want to redo the process every time I update Codeigniter folder.
System:
Codeigniter 3.0.6
PHP 7.0.8
Nginx 1.11.1
UPDATE: I'd like to call base_url on every error page (db, 404, general, php, etc.).