Bradley Coudriet trying to make the world better, one line of code at a time.

27Mar/082

Force SSL connection using PHP

When place before all other output on your PHP script this little snipped will force you PHP page to be presented over SSLThis 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']);
}
Tagged as: , , 2 Comments

Archives

Recent Comments

Tags

Blogroll

My Social Sites