<?php function force_https () {
if ( !is_ssl() ) {
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
exit();
}
}
add_action ( 'template_redirect', 'force_https', 1 );
?>
If you want to force pages to load over HTTPS, you need to add a little snippet so that even if someone tries to access your site over HTTP, they will be redirected to the HTTPS version of the page they’re trying to reach.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.