How to remove rest api link: in http headers?

The output is generated by the rest_output_link_header(). This function is used in two actions, wp_head and template_redirect in default-filters.php:@line234. You can remove the function from those hooks to remove the output you wanted to remove. Put the following codes in your theme’s functions.php to achieve the desired result.

remove_action( 'wp_head', 'rest_output_link_wp_head', 10);    
remove_action( 'template_redirect', 'rest_output_link_header', 11);

Both actions are defined in ABSPATH/wp-includes/default-filters.php under // REST API filters.

Leave a Comment