I have Apache and PHP setup and i am using a .htaccess file to auto_prepend a file to any output.
The problem is when I want to output a 404 error using
<?php header("HTTP/1.0 404 Not Found"); ?>
It still outputs the header as the auto_prepended file has already been processed.
.htaccess file
php_value date.timezone 'Europe/London'
php_value auto_prepend_file load.php
load.php
<?php
// Set the error reporting level (DEV)
error_reporting(E_ALL);
ini_set("display_errors", 1);
// Load the configuration file
include("config/config.php");
session_start();
?>
So the load file includes the include for the config file so that it is set on every page that loads.
So at the moment I have some pages which are giving soft 404 errors rather than actual 404 errors, so if there is no data returned for say browsing to /image/123 because image 123 doesnt actually exist, I output a “This image doesnt exist” so this then causes problem for google or any other crawler as it can keep going from /image/123 …. /image/12222222333333444444 etc… So it actually needs to output a proper 404.
Hope someone can help.
I have found the answer in: PHP header 404 not working
This gives the correct 404 output.