Skip to content

Commit c021395

Browse files
committed
Try to guess the appropriate protocol when generating the site URL
1 parent 40f15d4 commit c021395

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

qa-include/app/options.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,13 @@ function qa_default_option($name)
398398

399399
switch ($name) {
400400
case 'site_url':
401-
$value = 'http://' . @$_SERVER['HTTP_HOST'] . strtr(rtrim(dirname($_SERVER['SCRIPT_NAME']), '/'), '\\', '/') . '/';
401+
$protocol =
402+
(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ||
403+
(!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] === 'on') ||
404+
(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
405+
? 'https'
406+
: 'http';
407+
$value = $protocol . '://' . @$_SERVER['HTTP_HOST'] . strtr(rtrim(dirname($_SERVER['SCRIPT_NAME']), '/'), '\\', '/') . '/';
402408
break;
403409

404410
case 'site_title':

0 commit comments

Comments
 (0)