PITS /
01429: UrlScheme building condition never match $_SERVER['HTTPS'] == 'on'
Summary: UrlScheme building condition never match $_SERVER['HTTPS'] == 'on'
Created: 2018-05-04 08:13
Status: Open
Category: Bug
Assigned:
Priority: 4
Version: all
OS: nginx/apache/haproxy
Description: The PHP Variable $_SERVER['HTTPS'] doesn't exists. Change to $_SERVER['HTTP_HTTPS'].
Patch:
--- a/pmwiki.php +++ b/pmwiki.php @@ -79,7 +79,7 @@ $RecentChangesFmt = array( '* [[{$Group}.{$Name}]] . . . $CurrentTime $[by] $AuthorLink: [=$ChangeSummary=]', '$Group.RecentChanges' => '* [[{$Group}/{$Name}]] . . . $CurrentTime $[by] $AuthorLink: [=$ChangeSummary=]'); -$UrlScheme = (@$_SERVER['HTTPS']=='on' || @$_SERVER['SERVER_PORT']==443) +$UrlScheme = (@$_SERVER['HTTP_HTTPS']=='on' || @$_SERVER['SERVER_PORT']==443) ? 'https' : 'http'; $ScriptUrl = $UrlScheme.'://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; $PubDirUrl = preg_replace('#/[^/]*$#', '/pub', $ScriptUrl, 1);
PwnyTail? May 04, 2018, at 08:15 AM
$_SERVER['HTTPS'] does exist on some servers. If for some reason your server doesn't provide $_SERVER['HTTPS'] and especially if you run on a different port (as the second condition also fails), you can always set $ScriptUrl
and $PubDirUrl
in config.php. I'll review the documentation to see if it is reliable to only use $_SERVER['HTTP_HTTPS'] as a check if the other 2 conditions do fail. --Petko May 04, 2018, at 09:41 AM