note 69959 deleted from function.getenv by danbrown

From: Date: Sun, 20 Jul 2008 00:17:42 +0000
Subject: note 69959 deleted from function.getenv by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-141831@lists.php.net to get a copy of this message
Note Submitter: kev at kevinhebert dot com ---- This came in really handy, I looked everywhere on the Internet for a simple answer to this and the solution turned out to be pleasantly simple. Let's say you have a secure server. You want everyone to use this secure server every time they access. But, you don't want to cut off http access entirely because people do forget to type that in the address bar. Just stick this at the top of your PHP script or in your header file: if (!$_SERVER["HTTPS"]) { header("Location: https://your.secure.server.com/\n\n"); exit; } I am testing this now but so far it works great, how would all of you all normally handle this (without forcing .htaccess passwords and doing the redirect that way, just for general users)? I tried web searches along the lines of "apache http https in different directories" and "force https access redirect apache" but nothing really worked as simply as this did.

« previous php.notes (#141831) next »