Issue a 404 if a permalink request does not match any posts.

git-svn-id: https://develop.svn.wordpress.org/trunk@1850 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2004-11-10 04:01:46 +00:00
parent 05c8a88de8
commit 111d7005e6
1 changed files with 10 additions and 0 deletions

View File

@ -184,6 +184,16 @@ if (1 == count($posts)) {
}
}
// Issue a 404 if a permalink request doesn't match any posts. Don't issue a
// 404 if one was already issued, if the request was a search, or if the
// request was a regular query string request rather than a permalink request.
if ( (0 == count($posts)) && !is_404() && !is_search()
&& !empty($_SERVER['QUERY_STRING']) &&
(false === strpos($_SERVER['REQUEST_URI'], '?')) ) {
$wp_query->is_404 = true;
header("HTTP/1.x 404 Not Found");
}
$wp_did_header = true;
endif;