Created
May 14, 2015 20:44
-
-
Save misterhon/0f1122db0f520df7d153 to your computer and use it in GitHub Desktop.
MU-Plugin to force SSL for a specific WordPress page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: SSL Redirect | |
* Description: Redirects a specific page to HTTPS | |
*/ | |
if ( ! function_exists( 'force_https' ) ) { | |
function force_https() { | |
if ( is_page( 'some-page-slug-here' ) && !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