Notice: Undefined index: HTTPS

Hi,

I have a small little problem that kinda bugs me for a while now and thought I would try to fix it once and for all.


<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];}
else {$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; }
return $pageURL;}
?>

Any ideas how can I fix this error here?

if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'))

Thanks a lot,

That fixed it! :slight_smile:

if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'))

This code shows the scenario “Operation Success but the Patient was Died.” Because, The error was undefined index HTTPS in the $_SERVER Variable. My goal is to navigate a http page to https page. But this code automatically leads to the else part. It only helps to fix the E_NOTICE & E_WARNING

Give me the best solution to redirect http to https…