Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Last active September 20, 2017 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wpscholar/1394310 to your computer and use it in GitHub Desktop.
Save wpscholar/1394310 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