Notice: Undefined index: HTTPS


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.

function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
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…