Posted by wd on 02/18/06 13:12
I just wanted to follow up on this thread. I finally got a chance to try
the recommended solutions and neither of the works.
I have an .htaccess file rewriting the URLs. So even though it looks like
the browser is visiting http://www.my_site.com/page1.html, PHP still
thinks the $_SERVER["QUERY_STRING"] is p=page1 (from
http://www.my_site.com/index.php?p=page1).
So every page except the home page ends up as a 404 not found error.
In the end, this solution worked -- PHP reads the URL and looks for a
question mark:
<?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;
}
?>
Navigation:
[Reply to this message]
|