Force SSL by loading the same page via HTTPS

Just a simple one, I place this in a common file, and then call it at the top of each page that I require to be secured by SSL.

function force_ssl() {
    if ($_SERVER['HTTPS'] != 'on') {
        header("Location: https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
        exit();
    }
}

No related posts.

This entry was posted in Code Stuff and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>