Skip to content

Instantly share code, notes, and snippets.

@seangates
Forked from martynchamberlin/gist:5278521
Last active August 29, 2015 14:02
Show Gist options
  • Save seangates/23290bd3946cbe5c2a0e to your computer and use it in GitHub Desktop.
Save seangates/23290bd3946cbe5c2a0e to your computer and use it in GitHub Desktop.
<?php
$using_ssl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || $_SERVER['SERVER_PORT'] == 443;
add_action('wp', 'check_ssl');
function check_ssl()
{
$page_id = 2;// Page ID 2 must be https
if (is_page($page_id) && !$using_ssl)
{
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://' . $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
exit;
}
// All other pages must not be https
else if (!is_page($page_id) && $using_ssl)
{
header('Location: http://' . $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
exit;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment