Redirecting from HTTP to HTTPS with PHP

Force HTTPS

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

Usage

Call the function at the point you want to force https or on top of your global include file so to redirect on any page.


Comments

pripankaj
Posted on 14.10.2019 10:16

buy linkedin endorsements

[url=https://buylinkedin.com/]buy linkedin connection[/url]


http://buylinkedin.com/

Add your comment