Created
October 21, 2024 21:52
-
-
Save themightymo/685840991c9efae371a5ecbbf9a4aa80 to your computer and use it in GitHub Desktop.
Enable HSTS via WordPress functions.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Enables the HTTP Strict Transport Security (HSTS) header in WordPress. | |
* Includes preloading with subdomain support. | |
* via https://thomasgriffin.com/enable-http-strict-transport-security-hsts-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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment