我网站上的帖子的HTTP标题如下所示:
accept-ranges:bytes
cache-control:public, max-age=0,public,public
content-encoding:gzip
content-length:5369
content-type:text/html; charset=UTF-8
date:Fri, 08 Dec 2017 07:27:40 GMT
expires:Fri, 08 Dec 2017 07:19:33 GMT
link:<https://example.com/?p=5697>; rel=shortlink
server:Apache
status:200
vary:Accept-Encoding如何从HTTP报头响应中删除这一行:
link:<https://example.com/?p=5697>; rel=shortlink请不要将它与<head> </head>的HTML部分混为一谈,我已经从那里删除了它,我也想从header响应中删除它。
发布于 2017-12-08 08:56:33
<?php
add_filter('after_setup_theme', 'remove_redundant_shortlink');
function remove_redundant_shortlink() {
// remove HTML meta tag
// <link rel='shortlink' href='http://example.com/?p=25' />
remove_action('wp_head', 'wp_shortlink_wp_head', 10);
// remove HTTP header
// Link: <https://example.com/?p=25>; rel=shortlink
remove_action( 'template_redirect', 'wp_shortlink_header', 11);
}在WordPress 4.4中测试,最多4.9.1
发布于 2022-01-17 12:22:50
这在wordpress 5.8.3中仍然有效,如果您将其放在主题functions.php中--请记住,该文件在升级时可能会更改。
解决方案是这里
https://wordpress.stackexchange.com/questions/288089
复制相似问题