HSTS Header (WP)

PHOTO EMBED

Tue Sep 24 2024 13:43:24 GMT+0000 (Coordinated Universal Time)

Saved by @TitaMC #php

/** 
 * Enables the HTTP Strict Transport Security (HSTS) header in WordPress. 
 */
function tg_enable_strict_transport_security_hsts_header_wordpress() {
    header( 'Strict-Transport-Security: max-age=31536000; includeSubDomains; preload' );
}
add_action( 'send_headers', 'tg_enable_strict_transport_security_hsts_header_wordpress' );
content_copyCOPY

Add to functions.php. Preload at https://hstspreload.org/