Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
in Plugins by

Is is possible to "raise" a 404 error in the process_request function in a page plugin? Currently I set $qa_content['error'] then return it, which shows an error.

But it still shows a 200 OK status, should I add the 404 manually via header() or is there a Q2A function I can call?

Q2A version: 1.5.2

1 Answer

+1 vote

The 404 response is handled at the server level. Once your php file starts executing, the server's 404 handler is already disengaged.

Using header('HTTP/1.0 404 Not Found') is correct. Any bot or other client should be able to recognize that and treat it just as they would a server-supplied 404.

The 200 after completion of the php is normal.

You can also use readfile('your_default_404_page') if this is what you want.


  header('HTTP/1.0 404 Not Found');
That's fine, I was wondering if there was a Q2A function that covered all that, since Q2A uses 404s in a few places.