I’m getting an error message from a piece of code in a Drupal site I’ve been working on.
function getAddress()
{
/*** check for https ***/
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
/*** return the full address ***/
//return
//$protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
return $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
$redirectURL = "http://www.example.com/menu";
$oneURL = "www.example.com/one/menu";
$twoURL = "www.example.com/two/menu";
$threeURL = "www.example.com/three/menu";
$fourURL = "www.example.com/four/menu";
$fiveURL = "www.example.com/five/menu";
$sixURL = "www.example.com/six/menu";
if(getAddress()==$oneURL || getAddress()==$twoURL || getAddress()==$threeURL || getAddress()==$fourURL || getAddress()==$fiveURL || getAddress()==$sixURL)
{
header('Location:'.$redirectURL);
}
//echo getAddress();
I didn’t write this code. I’m just coming into this site. From what I can figure, it checks for whether the website is requested through http or https and rewrites accordingly. But I’m not sure as I’m still very wet behind the ears with PHP.
Anyway, these are the errors that I get from this code
I get this 6 times.
Notice: Undefined index: HTTPS in /home/example/public_html/index.php on line 19
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/example/public_html/index.php:19) in /home/example/public_html/includes/bootstrap.inc on line 1031
This is for lines 630 thru 633
Warning: Cannot modify header information - headers already sent by (output started at /home/example/public_html/index.php:19) in /home/example/public_html/includes/bootstrap.inc on line 630
I know that this code is involved with all of these errors because when I comment it out they all go away. Anyone have any idea of what in this code is creating these errors? Or even specifically what the code does and how vital it is?