How To Remove Shortlink From HTTP Header WordPress
Do you want to Remove Shortlink From the HTTP Header of your website? As we know that WordPress 4.2 and above version added rel=’shortlink’ in the HTTP header Response.
What is shortlink in Http header?
Shortlink is nothing but the shorter version of the post or page URL. Which creates a separate request on the respective web page. So it is better you should remove it. Mostly WordPress added this by considering the SEO factor.
For example, this page has the following short link but you can’t search because we have already disabled this option
<link rel='shortlink' href='https://www.gomahamaya.com/?p=2047' />
In the above
?p=ID
represent the page ID with the number. Removing Shortlink From the HTTP Header of your website will not affect your website SEO but it will increase your website performance a little bit.
To remove rel=shortlink from your website you need to paste the following code inside the function.php file. This is without the plugin method.
add_filter('after_setup_theme', 'gomaya_remove_shortlink');
function gomaya_remove_shortlink() {
remove_action('wp_head', 'wp_shortlink_wp_head', 10);
remove_action( 'template_redirect', 'wp_shortlink_header', 11);
}
If you want to do same work by using a plugin then you should use the Remove WP version and shortlink plugin. This is a free plugin but if you want a premium version then you should use perfmatters. Which have so many features apart from this
Once you activate the plugin just enable the Remove Shortlink option in perfmatters Plugin and you are ready to rock.
Thanks for your code rahul
This was very helpful, thank you!