Forum Moderators: coopster
$w = isset($_GET['w']) ? $_GET['w'] : null;
if (strpos($w, "http://www.example.com") === false)
{ header("HTTP/1.0 404 Not Found");
include($_SERVER['DOCUMENT_ROOT'].'/404.htm');
die;
}
173.000.000.000 - - [05/Aug/2012:00:39:08 +0200] "GET /jump.php?w=/folder/destination.pdf HTTP/1.0" 200 - www.example.com "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)" "93.000.000.000"
header("HTTP/1.0 404 Not Found", TRUE);
Location
The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource.
404 Not Found
The server has not found anything matching the Request-URI.
here's an example from the log, which seems to be 200
timing out with a blank page
Alex_TJ wrote:
rain - tried that out just now, and the 404 page shows, so at least that's all good.
There's something about or around 'header("HTTP/1.0 404 Not Found")' that's throwing the spanner in the works.
flush() afterwards?
<?php
header("HTTP/1.0 404 Not Found");
exit();
?>
<?php
http_response_code(404);
exit();
?>
<?php
header("Status: 404 Not Found");
exit();
?>
<?php
header("HTTP/1.0: 404 Not Found");
exit();
?>
<?php
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
exit();
?>
<?php
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
header("Status: 404 Not Found");
exit();
?>
<?php
if (!function_exists('http_response_code')) {
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
header("Status: 404 Not Found");
} else {
http_response_code(404);
}
include ($_SERVER['DOCUMENT_ROOT']."/404.html");
?>
The 404 page won't "kick in" when you send a 404 header from a PHP script.
You have to INCLUDE() the error page HTML content for people to see.
Without the HEADER directive sending the 404 response, the status as seen in the response would be 200 OK because the request has already been fulfilled by an internal file.
<?php
$w = isset($_GET['w']) ? $_GET['w'] : null;
if (strpos($w, "http://www.example.com") === false)
{ header("HTTP/1.0 404 Not Found");
echo "oops";
die;
}
?> header("Status: 404 Not Found");?
<META HTTP-EQUIV=Refresh CONTENT="1; URL=<? echo $w; ?>">