Page 1 of 1

php restrict https

Posted: Wed Aug 04, 2010 7:25 pm
by Saman
There are some situation that you need to only allow access to your php ,pages only through SSL. You may use the following code at the beginning of the page. This will reload the page with https.

Code: Select all

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