Mobile app version of vmapp.org
Login or Join
Chiappetta492

: Is there any way to prevent the Google toolbar from breaking Friendly 404s This might be considered a continuation of this question. If I output HTML after my 404 header, It displays properly

@Chiappetta492

Posted in: #GoogleToolbar #Php

This might be considered a continuation of this question.

If I output HTML after my 404 header, It displays properly in IE and FF unless the user has Google bar instaled.
If I try

header('HTTP/1.x 404 Not Found');
header("Location: www.example.com/?content=404_error );
die();


then I'm getting 302 from the redirect. It seems to overrule the 404

Supposedly if your output is larger than 512 bytes, the toolbar isn't supposed to override the page, but It seems to do it anyway.

I found a setting in Google's Toolbar that said "Provide suggestions on navigation errors". Turning that off provides me with the behaviour I want my visitors to experience. Does anyone know if Google provides a way for a developer to over-ride that setting for all visitors?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Chiappetta492

1 Comments

Sorted by latest first Latest Oldest Best

 

@Heady270

It looks like are both trying to put a "404 Not Found" status and redirect to the error page contents. The "Location" header is really only valid for 3xx status codes like 301, and 302. I'm surprised that browsers are honoring your request to go to a different location with a 404 status.

To make it work you need to one of two things. Either issue a 302 status instead of a 404 when you redirect to the error page or serve the contents of the error page directly under the 404 status instead of trying to redirect to them.

Here is code for the first

header('302 Moved');
header("Location: www.example.com/?content=404_error );
die();


Here is some psuedo code for the second (which is the method that I would use.)

header('200 OK'); #include 404_content
die();

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme