CodeIgniter Forums

Full Version: $this->output->set_status_header( '404' );
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I am having issues with this:

PHP Code:
if ( $this->data['totalRecordsAvailable'] == )
   $this->output->set_status_header'404' );

I go via Cloudflare and when I get zero records, instead of it going to my web page stating that it takes me to a Cloudflare 404 page.

When I remove the code it takes me to the right page but the 404 is not set.

How can I make this work?

I think, you use the status code "404 Not Found" in incorrect way. You show HTML in both cases, right? In both cases the page exists, it just sometimes says that there are no records available.

IMO remove this:

if ( $this->data['totalRecordsAvailable'] == 0 )
    $this->output->set_status_header( '404' );

Oh sorry, I know exactly why there are no products available and that part is OK, it happens.

The code is right I think.

I have since found out that Cloudflare, by default, enable an App called SmartErrors that hijacks your 404's thinking that it can do a better job of helping the user than my site can.

The moment I disabled the App all was well.

thanks for your reply.