diff --git a/core/includes/common.inc b/core/includes/common.inc
index 17e1363..f36cb0d 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -3073,7 +3073,7 @@ function drupal_pre_render_styles($elements) {
         // for the aggregate file.
         if (isset($group['data'])) {
           $element = $link_element_defaults;
-          $element['#attributes']['href'] = file_create_url($group['data']);
+          $element['#attributes']['href'] = file_create_url($group['data'], TRUE);
           $element['#attributes']['media'] = $group['media'];
           $element['#browsers'] = $group['browsers'];
           $elements[] = $element;
@@ -3099,7 +3099,7 @@ function drupal_pre_render_styles($elements) {
               // browser-caching. IE7 does not support a media type on the
               // @import statement, so we instead specify the media for the
               // group on the STYLE tag.
-              $import[] = '@import url("' . check_plain(file_create_url($item['data']) . '?' . $query_string) . '");';
+              $import[] = '@import url("' . check_plain(file_create_url($item['data'], TRUE) . '?' . $query_string) . '");';
             }
           }
           // In addition to IE's limit of 31 total CSS inclusion tags, it also
@@ -3134,7 +3134,7 @@ function drupal_pre_render_styles($elements) {
             // The dummy query string needs to be added to the URL to control
             // browser-caching.
             $query_string_separator = (strpos($item['data'], '?') !== FALSE) ? '&' : '?';
-            $element['#attributes']['href'] = file_create_url($item['data']) . $query_string_separator . $query_string;
+            $element['#attributes']['href'] = file_create_url($item['data'], TRUE) . $query_string_separator . $query_string;
             $element['#attributes']['media'] = $item['media'];
             $element['#browsers'] = $group['browsers'];
             $elements[] = $element;
@@ -3230,7 +3230,7 @@ function drupal_build_css_cache($css) {
         $contents = drupal_load_stylesheet($stylesheet['data'], TRUE);
 
         // Build the base URL of this CSS file: start with the full URL.
-        $css_base_url = file_create_url($stylesheet['data']);
+        $css_base_url = file_create_url($stylesheet['data'], TRUE);
         // Move to the parent.
         $css_base_url = substr($css_base_url, 0, strrpos($css_base_url, '/'));
         // Simplify to a relative URL if the stylesheet URL starts with the
@@ -4042,7 +4042,7 @@ function drupal_pre_render_scripts($elements) {
     // script element for this file.
     if ($group['type'] == 'file' && isset($group['data'])) {
       $element = $element_defaults;
-      $element['#attributes']['src'] = file_create_url($group['data']);
+      $element['#attributes']['src'] = file_create_url($group['data'], TRUE);
       $element['#browsers'] = $group['browsers'];
       $elements[] = $element;
     }
@@ -4071,7 +4071,7 @@ function drupal_pre_render_scripts($elements) {
           case 'file':
             $query_string = empty($item['version']) ? $default_query_string : $js_version_string . $item['version'];
             $query_string_separator = (strpos($item['data'], '?') !== FALSE) ? '&' : '?';
-            $element['#attributes']['src'] = file_create_url($item['data']) . $query_string_separator . ($item['cache'] ? $query_string : REQUEST_TIME);
+            $element['#attributes']['src'] = file_create_url($item['data'], TRUE) . $query_string_separator . ($item['cache'] ? $query_string : REQUEST_TIME);
             break;
 
           case 'external':
diff --git a/core/includes/file.inc b/core/includes/file.inc
index 133d64f..144bae7 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -432,6 +432,9 @@ function file_stream_wrapper_get_instance_by_scheme($scheme) {
  * @param $uri
  *   The URI to a file for which we need an external URL, or the path to a
  *   shipped file.
+ * @param $this_server
+ *   If TRUE, return a URI that is relative to the current scheme, server,
+ *   and port.
  *
  * @return
  *   A string containing a URL that may be used to access the file.
@@ -441,7 +444,7 @@ function file_stream_wrapper_get_instance_by_scheme($scheme) {
  *
  * @see http://drupal.org/node/515192
  */
-function file_create_url($uri) {
+function file_create_url($uri, $this_server = FALSE) {
   // Allow the URI to be altered, e.g. to serve a file from a CDN or static
   // file server.
   drupal_alter('file_url', $uri);
@@ -462,23 +465,40 @@ function file_create_url($uri) {
     else {
       // If this is not a properly formatted stream, then it is a shipped file.
       // Therefore, return the urlencoded URI with the base URL prepended.
-      return $GLOBALS['base_url'] . '/' . drupal_encode_path($uri);
+      if ($this_server) {
+        return $GLOBALS['base_path'] . drupal_encode_path($uri);
+      }
+      else {
+        return $GLOBALS['base_url'] . '/' . drupal_encode_path($uri);
+      }
     }
   }
   elseif ($scheme == 'http' || $scheme == 'https') {
     // Check for http so that we don't have to implement getExternalUrl() for
     // the http wrapper.
-    return $uri;
+    // Leave $uri unchanged.
   }
   else {
     // Attempt to return an external URL using the appropriate wrapper.
     if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
-      return $wrapper->getExternalUrl();
+      $uri = $wrapper->getExternalUrl();
     }
     else {
       return FALSE;
     }
   }
+
+  if ($this_server) {
+    $parse_url = parse_url($uri);
+    $uri = $parse_url['path'];
+    if (!empty($parse_url['query'])) {
+      $uri .= '?' . htmlspecialchars($parse_url['query']);
+    }
+    if (!empty($parse_url['fragment'])) {
+      $uri .= '#' . $parse_url['fragment'];
+    }
+  }
+  return $uri;
 }
 
 /**
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index f807979..a20fdd2 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1344,10 +1344,10 @@ function theme_get_setting($setting_name, $theme = NULL) {
       // Generate the path to the logo image.
       if ($cache[$theme]['toggle_logo']) {
         if ($cache[$theme]['default_logo']) {
-          $cache[$theme]['logo'] = file_create_url(dirname($theme_object->filename) . '/logo.png');
+          $cache[$theme]['logo'] = file_create_url(dirname($theme_object->filename) . '/logo.png', TRUE);
         }
         elseif ($cache[$theme]['logo_path']) {
-          $cache[$theme]['logo'] = file_create_url($cache[$theme]['logo_path']);
+          $cache[$theme]['logo'] = file_create_url($cache[$theme]['logo_path'], TRUE);
         }
       }
 
@@ -1355,14 +1355,14 @@ function theme_get_setting($setting_name, $theme = NULL) {
       if ($cache[$theme]['toggle_favicon']) {
         if ($cache[$theme]['default_favicon']) {
           if (file_exists($favicon = dirname($theme_object->filename) . '/favicon.ico')) {
-            $cache[$theme]['favicon'] = file_create_url($favicon);
+            $cache[$theme]['favicon'] = file_create_url($favicon, TRUE);
           }
           else {
-            $cache[$theme]['favicon'] = file_create_url('core/misc/favicon.ico');
+            $cache[$theme]['favicon'] = file_create_url('core/misc/favicon.ico', TRUE);
           }
         }
         elseif ($cache[$theme]['favicon_path']) {
-          $cache[$theme]['favicon'] = file_create_url($cache[$theme]['favicon_path']);
+          $cache[$theme]['favicon'] = file_create_url($cache[$theme]['favicon_path'], TRUE);
         }
         else {
           $cache[$theme]['toggle_favicon'] = FALSE;
diff --git a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php
index 3a46916..210860b 100644
--- a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php
+++ b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php
@@ -88,7 +88,7 @@ class ColorTest extends WebTestBase {
 
     $this->drupalGet('<front>');
     $stylesheets = variable_get('color_' . $theme . '_stylesheets', array());
-    $this->assertPattern('|' . file_create_url($stylesheets[0]) . '|', 'Make sure the color stylesheet is included in the content. (' . $theme . ')');
+    $this->assertPattern('|' . file_create_url($stylesheets[0], TRUE) . '|', 'Make sure the color stylesheet is included in the content. (' . $theme . ')');
 
     $stylesheet_content = join("\n", file($stylesheets[0]));
     $this->assertTrue(strpos($stylesheet_content, 'color: #123456') !== FALSE, 'Make sure the color we changed is in the color stylesheet. (' . $theme . ')');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
index 1b07174..b74a76a 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
@@ -112,7 +112,7 @@ class JavaScriptTest extends WebTestBase {
     $javascript = drupal_get_js();
 
     $expected_1 = '<script type="text/javascript" src="http://example.com/script.js?' . $default_query_string . '" async="async"></script>';
-    $expected_2 = '<script type="text/javascript" src="' . file_create_url('core/misc/collapse.js') . '?' . $default_query_string . '" async="async"></script>';
+    $expected_2 = '<script type="text/javascript" src="' . file_create_url('core/misc/collapse.js', TRUE) . '?' . $default_query_string . '" async="async"></script>';
 
     $this->assertTrue(strpos($javascript, $expected_1) > 0, t('Rendered external JavaScript with correct async attribute.'));
     $this->assertTrue(strpos($javascript, $expected_2) > 0, t('Rendered internal JavaScript with correct async attribute.'));
@@ -129,7 +129,7 @@ class JavaScriptTest extends WebTestBase {
     $javascript = drupal_get_js();
 
     $expected_1 = '<script type="text/javascript" src="http://example.com/script.js?' . $default_query_string . '" defer="defer"></script>';
-    $expected_2 = '<script type="text/javascript" src="' . file_create_url('core/misc/collapse.js') . '?' . $default_query_string . '" defer="defer"></script>';
+    $expected_2 = '<script type="text/javascript" src="' . file_create_url('core/misc/collapse.js', TRUE) . '?' . $default_query_string . '" defer="defer"></script>';
 
     $this->assertTrue(strpos($javascript, $expected_1) > 0, t('Rendered external JavaScript with correct defer attribute.'));
     $this->assertTrue(strpos($javascript, $expected_2) > 0, t('Rendered internal JavaScript with correct defer attribute.'));
@@ -256,7 +256,7 @@ class JavaScriptTest extends WebTestBase {
     drupal_add_js('jQuery(function () { });', array('type' => 'inline', 'browsers' => array('IE' => FALSE)));
     $javascript = drupal_get_js();
 
-    $expected_1 = "<!--[if lte IE 8]>\n" . '<script type="text/javascript" src="' . file_create_url('core/misc/collapse.js') . '?' . $default_query_string . '"></script>' . "\n<![endif]-->";
+    $expected_1 = "<!--[if lte IE 8]>\n" . '<script type="text/javascript" src="' . file_create_url('core/misc/collapse.js', TRUE) . '?' . $default_query_string . '"></script>' . "\n<![endif]-->";
     $expected_2 = "<!--[if !IE]><!-->\n" . '<script type="text/javascript">' . "\n<!--//--><![CDATA[//><!--\n" . 'jQuery(function () { });' . "\n//--><!]]>\n" . '</script>' . "\n<!--<![endif]-->";
 
     $this->assertTrue(strpos($javascript, $expected_1) > 0, t('Rendered JavaScript within downlevel-hidden conditional comments.'));
@@ -289,10 +289,10 @@ class JavaScriptTest extends WebTestBase {
     drupal_add_js('core/misc/batch.js', array('every_page' => TRUE));
     $javascript = drupal_get_js();
     $expected = implode("\n", array(
-      '<script type="text/javascript" src="' . file_create_url('core/misc/collapse.js') . '?' . $default_query_string . '"></script>',
-      '<script type="text/javascript" src="' . file_create_url('core/misc/batch.js') . '?' . $default_query_string . '"></script>',
-      '<script type="text/javascript" src="' . file_create_url('core/misc/ajax.js') . '?' . $default_query_string . '"></script>',
-      '<script type="text/javascript" src="' . file_create_url('core/misc/autocomplete.js') . '?' . $default_query_string . '"></script>',
+      '<script type="text/javascript" src="' . file_create_url('core/misc/collapse.js', TRUE) . '?' . $default_query_string . '"></script>',
+      '<script type="text/javascript" src="' . file_create_url('core/misc/batch.js', TRUE) . '?' . $default_query_string . '"></script>',
+      '<script type="text/javascript" src="' . file_create_url('core/misc/ajax.js', TRUE) . '?' . $default_query_string . '"></script>',
+      '<script type="text/javascript" src="' . file_create_url('core/misc/autocomplete.js', TRUE) . '?' . $default_query_string . '"></script>',
     ));
     $this->assertTrue(strpos($javascript, $expected) > 0, t('Unaggregated JavaScript is added in the expected group order.'));
 
@@ -309,8 +309,8 @@ class JavaScriptTest extends WebTestBase {
     $js_items = drupal_add_js();
     $javascript = drupal_get_js();
     $expected = implode("\n", array(
-      '<script type="text/javascript" src="' . file_create_url(drupal_build_js_cache(array('core/misc/collapse.js' => $js_items['core/misc/collapse.js'], 'core/misc/batch.js' => $js_items['core/misc/batch.js']))) . '"></script>',
-      '<script type="text/javascript" src="' . file_create_url(drupal_build_js_cache(array('core/misc/ajax.js' => $js_items['core/misc/ajax.js'], 'core/misc/autocomplete.js' => $js_items['core/misc/autocomplete.js']))) . '"></script>',
+      '<script type="text/javascript" src="' . file_create_url(drupal_build_js_cache(array('core/misc/collapse.js' => $js_items['core/misc/collapse.js'], 'core/misc/batch.js' => $js_items['core/misc/batch.js'])), TRUE) . '"></script>',
+      '<script type="text/javascript" src="' . file_create_url(drupal_build_js_cache(array('core/misc/ajax.js' => $js_items['core/misc/ajax.js'], 'core/misc/autocomplete.js' => $js_items['core/misc/autocomplete.js'])), TRUE) . '"></script>',
     ));
     $this->assertTrue(strpos($javascript, $expected) > 0, t('JavaScript is aggregated in the expected groups and order.'));
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php
index b4139e2..0528c81 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php
@@ -52,27 +52,27 @@ class ThemeTest extends WebTestBase {
       // Raw stream wrapper URI.
       $file->uri => array(
         'form' => file_uri_target($file->uri),
-        'src' => file_create_url($file->uri),
+        'src' => file_create_url($file->uri, TRUE),
       ),
       // Relative path within the public filesystem.
       file_uri_target($file->uri) => array(
         'form' => file_uri_target($file->uri),
-        'src' => file_create_url($file->uri),
+        'src' => file_create_url($file->uri, TRUE),
       ),
       // Relative path to a public file.
       $file_relative => array(
         'form' => $file_relative,
-        'src' => file_create_url($file->uri),
+        'src' => file_create_url($file->uri, TRUE),
       ),
       // Relative path to an arbitrary file.
       'core/misc/druplicon.png' => array(
         'form' => 'core/misc/druplicon.png',
-        'src' => $GLOBALS['base_url'] . '/' . 'core/misc/druplicon.png',
+        'src' => $GLOBALS['base_path'] . 'core/misc/druplicon.png',
       ),
       // Relative path to a file in a theme.
       $default_theme_path . '/logo.png' => array(
         'form' => $default_theme_path . '/logo.png',
-        'src' => $GLOBALS['base_url'] . '/' . $default_theme_path . '/logo.png',
+        'src' => $GLOBALS['base_path'] . $default_theme_path . '/logo.png',
       ),
     );
     foreach ($supported_paths as $input => $expected) {
@@ -165,7 +165,7 @@ class ThemeTest extends WebTestBase {
 
     $this->drupalGet('');
     $elements = $this->xpath('//*[@id=:id]/img', array(':id' => 'logo'));
-    $this->assertEqual($elements[0]['src'], file_create_url($uploaded_filename));
+    $this->assertEqual($elements[0]['src'], file_create_url($uploaded_filename, TRUE));
   }
 
   /**
