how to check if ssl exists on a webserver through php?
<p>i have this function here that i have in a class</p>

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

<p>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</p>

<p>is it possible?</p>

<p>thanks.</p>

<p>ps: did some google research and couldnt find much of anything.</p>
