Forum Moderators: coopster

Message Too Old, No Replies

Sending a 404 Header

with PHP

         

Nick_W

7:16 am on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

Just checking and have discovered that this is not working as intended:


function page_not_found() {
header("HTTP/1.1 404 Not Found");
exit;
}

I call it when somthing goes awry in the code but when I check it, it's returning 200 OK

Anyone?

Nick

jaski

7:24 am on Sep 2, 2003 (gmt 0)

10+ Year Member



Just check if there is any thing getting echoed before this function is being called.

Header have to go out before any thing else does.

<added>
Also try

header("HTTP/1.0 404 Not Found");

Nick_W

7:32 am on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry Jaski, it works fine. I just havnt had enough coffee clearly ;)

Nick

jaski

7:35 am on Sep 2, 2003 (gmt 0)

10+ Year Member



cool :)

brotherhood of LAN

7:36 am on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'd not bother with the function since its only one line, makes for easier reading regardless of caffeine ;)

Nick_W

8:06 am on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd agree BOL if that was the real function! ;)

I only included the important bit heh!

Nick