【发布时间】:2021-12-07 19:17:51
【问题描述】:
我想将 wordpress 默认的 404 页面状态码(200 OK)更改为 404。 我试过这样做,但它仍然返回 404 页面,状态为 200 Ok。
add_action('template_redirect', '_custom_redirect');
function _custom_redirect() {
global $wp_query;
$wp_query->set_404();
status_header(404);
include( get_query_template( '404' ) );
exit;
}
我只需要为 Google 这样做。谷歌仍然索引很多旧网址,但不存在并且找不到返回 404。我想如果我将返回状态 404 它将停止索引(根据这个 video )
【问题讨论】: