diff options
Diffstat (limited to 'includes/locale.inc')
-rw-r--r-- | includes/locale.inc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/includes/locale.inc b/includes/locale.inc index 72e466802..bc2d58dd7 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -430,8 +430,27 @@ function locale_language_url_rewrite_url(&$path, &$options) { case LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN: if ($options['language']->domain) { // Ask for an absolute URL with our modified base_url. + global $is_https; + $url_scheme = ($is_https) ? 'https://' : 'http://'; $options['absolute'] = TRUE; - $options['base_url'] = $options['language']->domain; + + // Take the domain without ports or protocols so we can apply the + // protocol needed. The setting might include a protocol. + // This is changed in Drupal 8 but we need to keep backwards + // compatibility for Drupal 7. + $host = 'http://' . str_replace(array('http://', 'https://'), '', $options['language']->domain); + $host = parse_url($host, PHP_URL_HOST); + + // Apply the appropriate protocol to the URL. + $options['base_url'] = $url_scheme . $host; + if (isset($options['https']) && variable_get('https', FALSE)) { + if ($options['https'] === TRUE) { + $options['base_url'] = str_replace('http://', 'https://', $options['base_url']); + } + elseif ($options['https'] === FALSE) { + $options['base_url'] = str_replace('https://', 'http://', $options['base_url']); + } + } } break; |