我的网站上帖子的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的一部分,我已经从那里删除了它,我也想从HTTP头响应中删除它
最合适的回答,由SO网友:Max Yudin 整理而成
<?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中测试