I was trying to find an answer to the question of making one page use https and came across this thread
http://wordpress.org/extend/ideas/topic.php?id=2138
Seems like I’m not the only one. Anyway, this is what I came up with. I’m not a programmer so if someone can give me a more efficient method, please do.
add_action('wp', 'sslForPages');
function sslForPages(){
if ((is_page(453))||(is_page(430)) && empty($_SERVER['HTTPS'])){
$url = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
header ("location: $url");
}
}
Obviously, change the page ID and add or remove pages or compare using different criteria to suit you needs.
I’ve expanded this to cater for links within the site that weren’t absolute (to get off https when not needed).
function sslForPages(){ if ((is_page(453))||(is_page(430)) && empty($_SERVER['HTTPS'])){ $url = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; header ("location: $url"); } elseif(!((is_page(453))||(is_page(430))) && !empty($_SERVER['HTTPS']))}