Skip to content

Instantly share code, notes, and snippets.

@misterhon
Created May 14, 2015 20:44
Show Gist options
  • Save misterhon/0f1122db0f520df7d153 to your computer and use it in GitHub Desktop.
Save misterhon/0f1122db0f520df7d153 to your computer and use it in GitHub Desktop.
MU-Plugin to force SSL for a specific WordPress page
<?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