diff --git a/modules/locale/locale.admin.inc b/modules/locale/locale.admin.inc
index 7cdf190..2f1d6eb 100644
--- a/modules/locale/locale.admin.inc
+++ b/modules/locale/locale.admin.inc
@@ -743,6 +743,17 @@ function locale_language_providers_url_form_validate($form, &$form_state) {
       form_error($form['domain'][$langcode], t('The domain for %language, %value, is not unique.', array( '%language' => $name, '%value' => $value )));
     }
   }
+
+  // Domain names can not contain protocol and/or ports
+  foreach ($languages as $langcode => $name) {
+    $value = $form_state['values']['domain'][$langcode];
+    if (!empty($value)) {
+      $host = 'http://' . str_replace(array('http://', 'https://'), '', $value);
+      if (parse_url($host, PHP_URL_HOST) != $value) {
+        form_error($form['domain'][$langcode], t('The domain for %language may only contain the domain name, not a protocol and/or port.', array( '%language' => $name)));
+      }
+    }
+  }
 }
 
 /**
diff --git a/modules/locale/locale.install b/modules/locale/locale.install
index 7fbc81d..5fbd85a 100644
--- a/modules/locale/locale.install
+++ b/modules/locale/locale.install
@@ -255,3 +255,34 @@ function locale_schema() {
 
   return $schema;
 }
+
+/**
+ * Implements hook_update_N().
+ */
+function locale_update_8000() {
+  $message = '';
+  $languages = language_list('enabled');
+  // $used_domains keeps track of the domain names in use
+  $used_domains = array();
+  foreach ($languages[1] as $langcode => $language) {
+    // Domain names can not contain protocol and/or ports
+    if (!empty($language->domain)) {
+      $host = 'http://' . str_replace(array('http://', 'https://'), '', $language->domain);
+      if (parse_url($host, PHP_URL_HOST) != $language->domain) {
+        $language->domain = parse_url($host, PHP_URL_HOST);
+        locale_language_save($language);
+      }
+      if (array_key_exists($language->domain, $used_domains)) {
+        if (empty($message)) {
+          $message = 'Some languages are using the same domain name, you should change these domain names at ' . l('URL language detection configuration', 'admin/config/regional/language/configure/url');
+        }
+      }
+      else {
+        $used_domains[$language->domain] = $language->name;
+      }
+    }
+  }
+  if (!empty($message)) {
+    return $message;
+  }
+}
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index 854bd24..eb8d765 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -1886,7 +1886,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
 
     // Setup for domain negotiation, first configure the language to have domain
     // URL. We use https and a port to make sure that only the domain name is used.
-    $edit = array("domain[$langcode]" => "https://$language_domain:99");
+    $edit = array("domain[$langcode]" => "$language_domain");
     $this->drupalPost("admin/config/regional/language/configure/url", $edit, t('Save configuration'));
     // Set the site to use domain language negotiation.
 
