Welcome Guest, Not a member yet? Register   Sign In
$this->output->set_status_header( '404' );
#1

(This post was last modified: 01-18-2015, 09:18 AM by andyscraven.)

Hi

I am having issues with this:

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



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?

Thanks.
Reply
#2

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:

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

http://en.wikipedia.org/wiki/HTTP_404
Reply
#3

Hi

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.

Andy
Reply




Theme © iAndrew 2016 - Forum software by © MyBB