Re: checking for and enforcing https

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 25, 2008 at 2:09 PM, Daniel Brown <parasane@xxxxxxxxx> wrote:

> <?
>    if($_SERVER['SERVER_PORT'] != '443') {
>        $url = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] :
> $_SERVER['SERVER_NAME'];
>        header("Location:
> https://".$url.$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']);
>        exit;
>    }
> ?>
>
>

An alternative to this if you don't know the port would be to check
$_ENV["HTTPS"] for "off":

if ($_ENV["HTTPS"] == "off")  ... [insert the rest of Daniel's code here]


-- 
-Dan Joseph

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux