0

Is it possible to add a 404 Not Found error message to a page so that Google Crawler knows that it's a non-existent page, when output is already made to the browser?

Using the code below is not an option, since it results in a "Can not modify headers" error:

header("HTTP/1.0 404 Not Found");
1
  • No it's not possible to change the header after it has been printed/sent to the browser. Commented Aug 30, 2012 at 11:41

2 Answers 2

1

No.

Headers are always sent before data (hence the name ;-))

Send the header before any data and you are set.

Sign up to request clarification or add additional context in comments.

Comments

0

What is sent out to the browser is gone. You lost control as you cannot unsent it. You shall use output buffering if you need to change headers at various points of your app. Alternatively you can always set .htaccess with entry like ErrorDocument 404 /my-error404-script.php and deal with 404 in that script (if possible)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.