aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierrick Le Gall <plg@piwigo.org>2015-10-08 11:42:55 +0200
committerPierrick Le Gall <plg@piwigo.org>2015-10-08 11:42:55 +0200
commit950da505a04a4e8675b7a48a267a88f9cde0e7ab (patch)
tree307e28a1a2db724caea8cbe7a1537a1fa8e06338
parent9a622724fda3601cae710486f374f5e09d7abcba (diff)
parent6d01f33d9fa973c6209c1e6350aeea429b4c31b9 (diff)
Merge pull request #353 from holzgeist/develop
Use HTTP_X_FORWARDED_HOST if available
-rw-r--r--include/functions_url.inc.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php
index 5a471bc10..138a895e1 100644
--- a/include/functions_url.inc.php
+++ b/include/functions_url.inc.php
@@ -62,14 +62,21 @@ function get_absolute_root_url($with_scheme=true)
{
$url .= 'http://';
}
- $url .= $_SERVER['HTTP_HOST'];
- if ( (!$is_https && $_SERVER['SERVER_PORT'] != 80)
- ||($is_https && $_SERVER['SERVER_PORT'] != 443))
+ if (isset($_SERVER['HTTP_X_FORWARDED_HOST']))
{
- $url_port = ':'.$_SERVER['SERVER_PORT'];
- if (strrchr($url, ':') != $url_port)
+ $url .= $_SERVER['HTTP_X_FORWARDED_HOST'];
+ }
+ else
+ {
+ $url .= $_SERVER['HTTP_HOST'];
+ if ( (!$is_https && $_SERVER['SERVER_PORT'] != 80)
+ ||($is_https && $_SERVER['SERVER_PORT'] != 443))
{
- $url .= $url_port;
+ $url_port = ':'.$_SERVER['SERVER_PORT'];
+ if (strrchr($url, ':') != $url_port)
+ {
+ $url .= $url_port;
+ }
}
}
}