Re: checking for and enforcing https

From: Date: Mon, 25 Feb 2008 20:03:44 +0000
Subject: Re: checking for and enforcing https
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-270116@lists.php.net to get a copy of this message
On Mon, Feb 25, 2008 at 2:09 PM, Daniel Brown <parasane@gmail.com> 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."

« previous php.general (#270116) next »