diff --git a/core/includes/locale.inc b/core/includes/locale.inc
index e2a79b6..1afe588 100644
--- a/core/includes/locale.inc
+++ b/core/includes/locale.inc
@@ -439,7 +439,7 @@ function locale_language_url_rewrite_url(&$path, &$options) {
         if (!empty($domains[$options['language']->langcode])) {
           // Ask for an absolute URL with our modified base_url.
           $options['absolute'] = TRUE;
-          $options['base_url'] = $domains[$options['language']->langcode];
+          $options['base_url'] = 'http://' . $domains[$options['language']->langcode];
         }
         break;
 
diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test
index f102d4b..de19818 100644
--- a/core/modules/locale/locale.test
+++ b/core/modules/locale/locale.test
@@ -2212,6 +2212,41 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
     $fields = $this->xpath('//div[@id="site-name"]//a[@rel="home" and @href=:url]//span', $args);
     $this->assertTrue($fields[0] == 'Drupal', t('URLs are rewritten using the browser language.'));
   }
+
+  /**
+   * Test if the url function returns the right url when using different domains for different languages.
+   */
+  function testLanguageDomain() {
+    // Add the Italian language.
+    $langcode_browser_fallback = 'it';
+    $language = (object) array(
+      'langcode' => $langcode_browser_fallback,
+    );
+    language_save($language);
+    $languages = language_list();
+
+
+    // Enable browser and URL language detection.
+    $edit = array(
+      'language[enabled][locale-browser]' => TRUE,
+      'language[enabled][locale-url]' => TRUE,
+      'language[weight][locale-browser]' => -8,
+      'language[weight][locale-url]' => -10,
+    );
+    $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
+
+    // Enable the path prefix for the default language: this way any unprefixed
+    // URL must have a valid fallback value.
+    $edit = array(
+      'locale_language_negotiation_url_part' => 1,
+      'domain[it]' => 'it.example.com',
+    );
+    $this->drupalPost('admin/config/regional/language/configure/url', $edit, t('Save configuration'));
+
+    $italian_url = url('admin', array('language' => $languages['it']));
+    $correct_link = ($italian_url == 'http://it.example.com' . base_path() . '?q=admin');
+    $this->assertTrue($correct_link, t('The url() function returns the right url in accordance with the chosen language'));
+  }
 }
 
 /**
