Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active March 22, 2019 14:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/424dd8e120292ac4f9aa99a27ffbd788 to your computer and use it in GitHub Desktop.
Save billerickson/424dd8e120292ac4f9aa99a27ffbd788 to your computer and use it in GitHub Desktop.
<?php
/**
* Force SSL on WPEngine install
*
* @author Bill Erickson
* @see https://www.billerickson.net/force-ssl-on-wpengine
*
*/
function be_force_ssl_on_wpengine() {
if( strpos( home_url(), 'wpengine' ) && ! is_ssl() ) {
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
exit();
}
}
add_action( 'template_redirect', 'be_force_ssl_on_wpengine' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment