Skip to content

Instantly share code, notes, and snippets.

@theukedge
Created January 28, 2015 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theukedge/3ab56ab58614e3baa0b4 to your computer and use it in GitHub Desktop.
Save theukedge/3ab56ab58614e3baa0b4 to your computer and use it in GitHub Desktop.
Force HTTPS on all pages in WordPress
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment