how to check if ssl exists on a webserver through php?

Posted by sarmenhb on Stack Overflow See other posts from Stack Overflow or by sarmenhb
Published on 2009-05-23T06:06:35Z Indexed on 2010/06/02 15:33 UTC
Read the original article Hit count: 118

Filed under:

i have this function here that i have in a class

function enable_ssl() {
     if ($_SERVER[HTTPS]!="on") {
     $domain = "https://".$_SERVER['HTTP_HOST']."/".$_SERVER['SCRIPT_NAME'];
     header("Location: {$domain}");
     }
     }

but the problem is when the server doesnt have ssl installed and i have this function initiating the page redirects to a 404 page. i was wondering how i can have this function work only when ssl is installed and working

is it possible?

thanks.

ps: did some google research and couldnt find much of anything.

© Stack Overflow or respective owner

Related posts about php