[英]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.