I am working with a PHP shopping cart and using a mod that rewrites the URL. The issue is when a product is removed and the URL is called, the code generates a soft 404 page stating the product is not found, yet the HTTP status code is 200.
As a fix I added
header('HTTP/1.1 404 Not Found'); late in the page generation where the soft 404 text is generated (assuming after the original 200 code was send)
When I added this code and did a 'Fetch as Google' Google kicks back 'Not Found' which is what I want for products no longer in the store.
My question: Is sending a HTTP header status late in page generation after a 200 was sent OK to do?