You are here: 404 OK ? « PHP Programming Language « IT news, forums, messages
404 OK ?

Posted by wd on 11/19/04 11:46

I am using the following bit of code at the very top of my pages to send a
404 Not Found error when people try to access any URL with a query string
in it.

<?php
$url_string = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

if (strstr($url_string, '?')) {
header("HTTP/1.0 404 Not Found");
echo <<<HTML
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
The requested URL was not found on this server.
</body>
</html>
HTML;
exit;
}
?>

These are the headers that get sent back to the browser -- look at the
first line:

HTTP/1.x 404 OK
Date: Sun, 30 Apr 2006 11:13:37 GMT
Server: Apache/1.3.33 (Unix)
X-Powered-By: PHP/4.4.2
Keep-Alive: timeout=2, max=200
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

But for the missing favicon (which really does not exist) I get a regular
404 error message:

HTTP/1.x 404 Not Found



What is a "404 OK" header and why isn't it sending the "Not Found" header?
I am trying to get it to send a regular 404 Not Found header.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация