Remove REST API Link Tag from Head
Removes the REST API discovery link from the HTML head and HTTP Link header to reduce information exposure to scanners.
PHPby SnipCraft
php
<?php
/**
* Strips the REST API advertisement from every front-end page.
* The REST API itself continues to function normally — only its discovery
* links are removed.
*/
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'template_redirect', 'rest_output_link_header', 11 );
remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' );#hardening#headers#privacy#rest-api#security