0

I've spent many hours trying to get this to work; I've read endless posts and tried hundreds of combinations. I'm using a KVM vps so I can edit the apache config files directly if needed.

All I want to do is force https across my whole site (Easy) and exclude one page/post needs to be

I assume it's Wordpress's own permalink rewrite thats tripping me up some how.

Thanks!

0

I just used this in the functions file in the end

function force_ssl()
{
    // Specify ID of page to be viewed on SSL connection
if (is_page(8616) && !is_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(8616) && is_ssl() )
{
    header('Location: http://' . $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
    exit();
}
}      
add_action('template_redirect', 'force_ssl');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.