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 4 weeks ago

buy linkedin endorsements

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


http://buylinkedin.com/

Add your comment