Re: Re: Making sure page is always https

From: Date: Mon, 17 Jun 2002 21:32:58 +0000
Subject: Re: Re: Making sure page is always https
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-102609@lists.php.net to get a copy of this message
Is $_SERVER['HTTPS'] a defined variable? If so, cool -- but I don't see it here: http://www.php.net/manual/en/reserved.variables.php Might work -- I haven't tried that one. Similar idea, though, using variables that are there: // adjust if your SSL port isn't on port 443 if ($_SERVER['SERVER_PORT'] != "443") { // redirect } OR: if (!strstr($_SERVER['SERVER_PROTOCOL'],"HTTPS")) { // redirect } -Clay > From: "Ricky Dhatt" <ricky@electricarrow.com> > Organization: Electric Arrow > Reply-To: "Ricky Dhatt" <ricky@electricarrow.com> > Date: Mon, 17 Jun 2002 14:09:54 -0700 > To: php-general@lists.php.net > Subject: [PHP] Re: Making sure page is always https > > try something like this at the top of the PHP script: > > if (!_$SERVER['HTTPS']) { > header("Location: https://" . $_SERVER[HTTP_HOST] . > $_SERVER['REQUEST_URI']); > exit; > } > > On older versions of PHP you might need to use $HTTP_SERVER_VARS instead of > _$SERVER. > > Alternatively, if you are using Apache, I bet you can use mod_rewrite to do > something similar. > > Ricky > > > "Ben C." <benc@cox.net> wrote in message > news:NFBBJJIAAGFCPNFKMPGOAEKCDBAA.benc@cox.net... >> I have a site which I want to make sure is always being view via SSL. >> Currently I have the http://sslsafeserver/index.php page >> redirecting to >> https://sslsafeserver.com/home.php. Is there a way to have >> all pages > viewed >> in SSL through a PHP script? >> >> I appreciate the help. >> >> Ben >> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#102609) next »