diff --git a/includes/locale.inc b/includes/locale.inc
index f667d30b9c81b62b2229e5536ae2cb927cf94aab..b7d9672dfc66adab96468b4adacbb31d64ef543c 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -207,10 +207,16 @@ 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)) {
-          $language_url = $language->language;
-          break;
+        // Skip check if the language doesn't have a domain.
+        if ($language->domain) {
+          // Only compare the domains not the protocols or ports.
+          // Remove protocol and add http:// so parse_url works
+          $host = 'http://' . str_replace(array('http://', 'https://'), '', $language->domain);
+          $host = parse_url($host, PHP_URL_HOST);
+          if ($_SERVER['HTTP_HOST'] == $host) {
+            $language_url = $language->language;
+            break;
+          }
         }
       }
       break;
diff --git a/modules/locale/locale.admin.inc b/modules/locale/locale.admin.inc
index f3c1ae5f1dc9c380ef498842799cc920a9519951..d9044c6ee9cc41512603159e1b35505dea50dcd1 100644
--- a/modules/locale/locale.admin.inc
+++ b/modules/locale/locale.admin.inc
@@ -307,7 +307,7 @@ function _locale_languages_common_controls(&$form, $language = NULL) {
     '#title' => t('Language domain'),
     '#maxlength' => 128,
     '#default_value' => @$language->domain,
-    '#description' => t('URL <strong>including protocol</strong> to use for this language, if your <em>Detection and selection</em> settings use URL domains. For the default language, this value may be left blank. <strong>Modifying this value may break existing URLs. Use with caution in a production environment.</strong> Example: Specifying "http://example.de" or "http://de.example.com" as language domains for German results in URLs like "http://example.de/contact" and "http://de.example.com/contact", respectively.'),
+    '#description' => t('The domain name to use for this language if URL domains are used for <em>Detection and selection</em>. Leave blank for the default language. <strong>Changing this value may break existing URLs.</strong> Example: Specifying "de.example.com" as language domain for German will result in an URL like "http://de.example.com/contact".'),
   );
   $form['direction'] = array('#type' => 'radios',
     '#title' => t('Direction'),
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index 6dad7e08bec477107e6f47771c9357687445f29c..425f68cfa79abc86a482483550f5f57a639b1c6c 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -1900,8 +1900,8 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
     $this->assertResponse(404, "Unknown language path prefix should return 404");
 
     // Setup for domain negotiation, first configure the language to have domain
-    // URL.
-    $edit = array('prefix' => '', 'domain' => "http://$language_domain");
+    // URL. We use https and a port to make sure that only the domain name is used.
+    $edit = array('prefix' => '', 'domain' => "https://$language_domain:99");
     $this->drupalPost("admin/config/regional/language/edit/$language", $edit, t('Save language'));
     // Set the site to use domain language negotiation.