简体   繁体   English

How to remove or disable rel shortlink url with post id in http response header for wordpress 5+ and and below, without a plugin?

[英]How to remove or disable rel shortlink url with post id in http response header for wordpress 5+ and and below, without a plugin?

When you inspect your blog post in the Network tab of your Chrome browser, it looks like below:当您在Chrome浏览器的Network选项卡中检查您的blog post时,它如下所示:

Response Headers
cache-control: no-cache, no-store, must-revalidate
.....
.....
.....
link:<https://demo.com/?p=53>; rel=shortlink
server:Apache
.....
status:200
vary:Accept-Encoding
.....
.....

This exposes your blog post id这会暴露您的博客post id

All you need to do is as below in your functions.php file您需要做的就是在您的functions.php文件中如下所示

add_filter('after_setup_theme', 'my_disable_rel_shortlink'); add_filter('after_setup_theme', 'my_disable_rel_shortlink');

function my_disable_rel_shortlink() { remove_action( 'template_redirect', 'wp_shortlink_header', 11); function my_disable_rel_shortlink() { remove_action('template_redirect', 'wp_shortlink_header', 11); } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM