Skip to content

Commit 3a12798

Browse files
authored
Merge pull request #692 from pupi1985/patch-120
Try to guess the appropriate protocol when generating the site URL
2 parents b0cb0de + c021395 commit 3a12798

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
@@ -389,7 +389,13 @@ function qa_default_option($name)
389389

390390
switch ($name) {
391391
case 'site_url':
392-
$value = 'http://' . @$_SERVER['HTTP_HOST'] . strtr(rtrim(dirname($_SERVER['SCRIPT_NAME']), '/'), '\\', '/') . '/';
392+
$protocol =
393+
(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ||
394+
(!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] === 'on') ||
395+
(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
396+
? 'https'
397+
: 'http';
398+
$value = $protocol . '://' . @$_SERVER['HTTP_HOST'] . strtr(rtrim(dirname($_SERVER['SCRIPT_NAME']), '/'), '\\', '/') . '/';
393399
break;
394400

395401
case 'site_title':

0 commit comments

Comments
 (0)