Skip to content

Instantly share code, notes, and snippets.

@jimboobrien
Forked from wpscholar/force-ssl.php
Created September 20, 2017 23:30
Show Gist options
  • Save jimboobrien/56e4c18258a6bbd8b955578562c45801 to your computer and use it in GitHub Desktop.
Save jimboobrien/56e4c18258a6bbd8b955578562c45801 to your computer and use it in GitHub Desktop.
Force SSL on pages in WordPress
<?php
/**
* Force SSL on pages in WordPress
*/
function force_ssl(){
if( !is_ssl() ){
$url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
wp_redirect( $url, 301);
exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment