diff --git a/includes/locale.inc b/includes/locale.inc
index 780459b..b48fd48 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -207,8 +207,11 @@ function locale_language_from_url($languages) {
 
     case LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN:
       foreach ($languages as $language) {
-        $host = parse_url($language->domain, PHP_URL_HOST);
-        if ($host && ($_SERVER['HTTP_HOST'] == $host)) {
+        // Only compare the domains not the protocolls.
+        $server_host = str_replace(array('http://', 'https://'), array('', ''), $_SERVER['HTTP_HOST']);
+        $host = parse_url($language->domain, PHP_URL_HOST);
+        if ($host && ($server_host == $host)) {
           $language_url = $language->language;
           break;
         }
