When place before all other output on your PHP script this little snipped will force you PHP page to be presented over SSL
This is very useful on things like Login forms.
 
if($_SERVER['SERVER_PORT'] != '443') {
    //Force SSL upon this page
    header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
}

Leave a Reply