diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php
index ef59db9..d67cdef 100644
--- a/core/lib/Drupal/Core/Routing/UrlGenerator.php
+++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php
@@ -148,7 +148,6 @@ public function generate($name, $parameters = array(), $absolute = FALSE) {
    */
   public function generateFromRoute($name, $parameters = array(), $options = array()) {
     $options += array('prefix' => '');
-    $absolute = !empty($options['absolute']);
     $route = $this->getRoute($name);
     $this->processRoute($name, $route, $parameters);
 
@@ -159,6 +158,7 @@ public function generateFromRoute($name, $parameters = array(), $options = array
 
     $path = $this->getInternalPathFromRoute($route, $parameters);
     $path = $this->processPath($path, $options);
+
     if (!empty($options['prefix'])) {
       $path = ltrim($path, '/');
       $prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix'];
@@ -172,7 +172,25 @@ public function generateFromRoute($name, $parameters = array(), $options = array
       }
     }
 
+    // The base_url might be rewritten from the language rewrite in domain mode.
+    if (isset($options['base_url'])) {
+      $base_url = $options['base_url'];
+
+      if (isset($options['https'])) {
+        if ($options['https'] === TRUE) {
+          $base_url = str_replace('http://', 'https://', $base_url);
+        }
+        elseif ($options['https'] === FALSE) {
+          $base_url = str_replace('https://', 'http://', $base_url);
+        }
+      }
+
+      return $base_url . $path . $fragment;
+    }
+
     $base_url = $this->context->getBaseUrl();
+
+    $absolute = !empty($options['absolute']);
     if (!$absolute || !$host = $this->context->getHost()) {
       return $base_url . $path . $fragment;
     }
diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
index a30db19..9b9bc4f 100644
--- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
+++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
@@ -59,8 +59,8 @@
    *   - 'https': Whether this URL should point to a secure location. If not
    *     defined, the current scheme is used, so the user stays on HTTP or HTTPS
    *     respectively. TRUE enforces HTTPS and FALSE enforces HTTP.
-   *   - 'base_url': Only used internally, to modify the base URL when a language
-   *     dependent URL requires so.
+   *   - 'base_url': Only used internally by a path processor, for example, to
+   *     modify the base URL when a language dependent URL requires so.
    *   - 'prefix': Only used internally, to modify the path when a language
    *     dependent URL requires so.
    *   - 'script': Added to the URL between the base path and the path prefix.
@@ -132,6 +132,8 @@ public function getPathFromRoute($name, $parameters = array());
    *   - 'https': Whether this URL should point to a secure location. If not
    *     defined, the current scheme is used, so the user stays on HTTP or HTTPS
    *     respectively. TRUE enforces HTTPS and FALSE enforces HTTP.
+   *   - 'base_url': Only used internally by a path processor, for example, to
+   *     modify the base URL when a language dependent URL requires so.
    *   - 'prefix': Only used internally, to modify the path when a language
    *     dependent URL requires so.
    *
diff --git a/core/modules/language/src/Tests/LanguageSwitchingTest.php b/core/modules/language/src/Tests/LanguageSwitchingTest.php
index 16fa5ac..a39da66 100644
--- a/core/modules/language/src/Tests/LanguageSwitchingTest.php
+++ b/core/modules/language/src/Tests/LanguageSwitchingTest.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\language\Tests;
 
+use Drupal\language\Entity\ConfigurableLanguage;
+use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\simpletest\WebTestBase;
 
@@ -159,6 +161,69 @@ protected function doTestLanguageBlockAnonymous($block_label) {
   }
 
   /**
+   * Test languge switcher links for domain based negotiation
+   */
+
+  function testLanguageBlockWithDomain() {
+    // Add the Italian language.
+    ConfigurableLanguage::createFromLangcode('it')->save();
+
+    // Rebuild the container so that the new language is picked up by services
+    // that hold a list of languages.
+    $this->rebuildContainer();
+
+    $languages = $this->container->get('language_manager')->getLanguages();
+
+    // Enable browser and URL language detection.
+    $edit = array(
+      'language_interface[enabled][language-url]' => TRUE,
+      'language_interface[weight][language-url]' => -10,
+    );
+    $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
+
+    // Do not allow blank domain.
+    $edit = array(
+      'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
+      'domain[en]' => '',
+    );
+    $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
+    $this->assertText(t('The domain may not be left blank for English'), 'The form does not allow blank domains.');
+
+    // Change the domain for the Italian language.
+    $edit = array(
+      'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
+      'domain[en]' => \Drupal::request()->getHost(),
+      'domain[it]' => 'it.example.com',
+    );
+    $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
+    $this->assertText(t('The configuration options have been saved'), 'Domain configuration is saved.');
+
+    // Enable the language switcher block.
+    $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, array('id' => 'test_language_block'));
+
+    $this->drupalGet('');
+
+    /** @var \Drupal\Core\Routing\UrlGenerator $generator */
+    $generator = $this->container->get('url_generator');
+
+    // Verfify the English URL is correct
+    list($english_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', array(
+      ':id' => 'block-test-language-block',
+      ':hreflang' => 'en',
+    ));
+    $english_url = $generator->generateFromPath('user/2', array('language' => $languages['en']));
+    $this->assertEqual($english_url, (string) $english_link['href']);
+
+    // Verfify the Italian URL is correct
+    list($italian_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', array(
+      ':id' => 'block-test-language-block',
+      ':hreflang' => 'it',
+    ));
+    $italian_url = $generator->generateFromPath('user/2', array('language' => $languages['it']));
+    $this->assertEqual($italian_url, (string) $italian_link['href']);
+  }
+
+  /**
    * Test active class on links when switching languages.
    */
   function testLanguageLinkActiveClass() {
diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
index 2e0b3dc..7e7fdf3 100644
--- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
@@ -291,6 +291,32 @@ public function testAbsoluteURLGeneration() {
   }
 
   /**
+   * Confirms that explicitly setting the base_url works with generated routes
+   */
+  public function testBaseURLGeneration() {
+    $options = array('base_url' => 'http://www.example.com:8888');
+    $url = $this->generator->generateFromRoute('test_1', array(), $options);
+    $this->assertEquals('http://www.example.com:8888/hello/world', $url);
+
+    $options = array('base_url' => 'http://www.example.com:8888', 'https' => TRUE);
+    $url = $this->generator->generateFromRoute('test_1', array(), $options);
+    $this->assertEquals('https://www.example.com:8888/hello/world', $url);
+
+    $options = array('base_url' => 'https://www.example.com:8888', 'https' => FALSE);
+    $url = $this->generator->generateFromRoute('test_1', array(), $options);
+    $this->assertEquals('http://www.example.com:8888/hello/world', $url);
+
+    $this->routeProcessorManager->expects($this->once())
+      ->method('processOutbound')
+      ->with($this->anything());
+
+    $options = array('base_url' => 'http://www.example.com:8888', 'fragment' => 'top');
+    // Extra parameters should appear in the query string.
+    $url = $this->generator->generateFromRoute('test_1', array('zoo' => '5'), $options);
+    $this->assertEquals('http://www.example.com:8888/hello/world?zoo=5#top', $url);
+  }
+
+  /**
    * Test that the 'scheme' route requirement is respected during url generation.
    */
   public function testUrlGenerationWithHttpsRequirement() {
