note 43101 deleted from wrappers.http by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 09 Jun 2004 18:58:22 +0000 |
| Subject: | note 43101 deleted from wrappers.http by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-70520@lists.php.net to get a copy of this message | ||
Note Submitter: chris@discovery.org
----
I was trying to solve a problem on how to redirect the user to the same page but using HTTPS. After
finding no examples, I wrote the following script which works and passes all the variables as well:
//make sure we are using https, if not, redirect them to it
if(!ISSET($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != "on")
{
//redirect page to https version
$redirstr = "https://" . $_SERVER["HTTP_HOST"]
. $_SERVER["PHP_SELF"];
$first = true; //allow some special stuff to happen on the forst vcariable we add
//copy over each variable into new redirect url
foreach($_REQUEST as $k => $v)
{
if($first) //if furst time then copy a ? make instead of &
{
$redirstr .= "?";
$first = false;
}
else
$redirstr .= "&";
echo "k=$k and v=$v\n";
$redirstr .= $k . "=" . $v; //copy over variable and value
}
//build javascript redirect
echo "<script language=\"javascript\"> location.replace(\"" .
$redirstr .
"\"); </script>";
exit(); //make sure we dont do any more processing since redirecting
}