This is how I set header $this->output->set_status_header(‘404’); in controller:
<?php
class custom404 extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->output->set_status_header('404');
$this->view_data['page_title'] = 'Page not found';
$this->view_data['main_content'] = 'error404';
$this->load->view('template', $this->view_data);
}
}
?>
Then I need to somehow check status header 404 in the view?
Any advice beside sending another variable in $this->view_data?
Create a file called MY_Output.php in your application/core folder with the following code:
You can now echo out the last status code you set like so: