Index: wp-admin/admin-header.php
===================================================================
--- wp-admin/admin-header.php	(revision 19859)
+++ wp-admin/admin-header.php	(working copy)
@@ -55,7 +55,7 @@
 		'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
 		'time':'<?php echo time() ?>'
 	},
-	ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
+	ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
 	pagenow = '<?php echo $current_screen->id; ?>',
 	typenow = '<?php echo $current_screen->post_type; ?>',
 	adminpage = '<?php echo $admin_body_class; ?>',
Index: wp-admin/includes/image-edit.php
===================================================================
--- wp-admin/includes/image-edit.php	(revision 19859)
+++ wp-admin/includes/image-edit.php	(working copy)
@@ -67,7 +67,7 @@
 	<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo $meta['height']; ?>" />
 
 	<div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
-	<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url('admin-ajax.php'); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" />
+	<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" />
 	</div>
 
 	<div class="imgedit-submit">
Index: wp-admin/includes/media.php
===================================================================
--- wp-admin/includes/media.php	(revision 19859)
+++ wp-admin/includes/media.php	(working copy)
@@ -334,7 +334,7 @@
 //<![CDATA[
 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time(); ?>'};
-var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
+var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
 isRtl = <?php echo (int) is_rtl(); ?>;
 //]]>
 </script>
Index: wp-admin/includes/template.php
===================================================================
--- wp-admin/includes/template.php	(revision 19859)
+++ wp-admin/includes/template.php	(working copy)
@@ -1394,7 +1394,7 @@
 		'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
 		'time':'<?php echo time() ?>'
 	},
-	ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
+	ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
 	pagenow = '<?php echo $current_screen->id; ?>',
 	typenow = '<?php echo $current_screen->post_type; ?>',
 	adminpage = '<?php echo $admin_body_class; ?>',
Index: wp-admin/press-this.php
===================================================================
--- wp-admin/press-this.php	(revision 19859)
+++ wp-admin/press-this.php	(working copy)
@@ -304,7 +304,7 @@
 //<![CDATA[
 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
-var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'press-this', isRtl = <?php echo (int) is_rtl(); ?>;
+var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'press-this', isRtl = <?php echo (int) is_rtl(); ?>;
 var photostorage = false;
 //]]>
 </script>
Index: wp-includes/class-wp-editor.php
===================================================================
--- wp-includes/class-wp-editor.php	(revision 19859)
+++ wp-includes/class-wp-editor.php	(working copy)
@@ -584,7 +584,7 @@
 		}
 
 		if ( !is_admin() )
-			echo 'var ajaxurl = "' . admin_url('admin-ajax.php') . '";';
+			echo 'var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '";';
 ?>
 	</script>
 <?php
Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 19859)
+++ wp-includes/link-template.php	(working copy)
@@ -1834,7 +1834,7 @@
  * @uses get_home_url()
  *
  * @param  string $path   (optional) Path relative to the home url.
- * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https'.
+ * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
  * @return string Home url link with optional path appended.
 */
 function home_url( $path = '', $scheme = null ) {
@@ -1853,13 +1853,13 @@
  *
  * @param  int $blog_id   (optional) Blog ID. Defaults to current blog.
  * @param  string $path   (optional) Path relative to the home url.
- * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https'.
+ * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
  * @return string Home url link with optional path appended.
 */
 function get_home_url( $blog_id = null, $path = '', $scheme = null ) {
 	$orig_scheme = $scheme;
 
-	if ( !in_array( $scheme, array( 'http', 'https' ) ) )
+	if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
 		$scheme = is_ssl() && !is_admin() ? 'https' : 'http';
 
 	if ( empty( $blog_id ) || !is_multisite() )
@@ -1867,7 +1867,9 @@
 	else
 		$url = get_blog_option( $blog_id, 'home' );
 
-	if ( 'http' != $scheme )
+	if ( 'relative' == $scheme )
+		$url = preg_replace( '#^.+://[^/]*#', '', $url ); 
+	elseif ( 'http' != $scheme )
 		$url = str_replace( 'http://', "$scheme://", $url );
 
 	if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
@@ -1889,7 +1891,7 @@
  * @uses get_site_url()
  *
  * @param string $path Optional. Path relative to the site url.
- * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', or 'admin'.
+ * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
  * @return string Site url link with optional path appended.
 */
 function site_url( $path = '', $scheme = null ) {
@@ -1908,13 +1910,13 @@
  *
  * @param int $blog_id (optional) Blog ID. Defaults to current blog.
  * @param string $path Optional. Path relative to the site url.
- * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', or 'admin'.
+ * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
  * @return string Site url link with optional path appended.
 */
 function get_site_url( $blog_id = null, $path = '', $scheme = null ) {
 	// should the list of allowed schemes be maintained elsewhere?
 	$orig_scheme = $scheme;
-	if ( !in_array( $scheme, array( 'http', 'https' ) ) ) {
+	if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
 		if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
 			$scheme = 'https';
 		elseif ( ( 'login' == $scheme ) && force_ssl_admin() )
@@ -1930,7 +1932,9 @@
 	else
 		$url = get_blog_option( $blog_id, 'siteurl' );
 
-	if ( 'http' != $scheme )
+	if ( 'relative' == $scheme )
+		$url = preg_replace( '#^.+://[^/]*#', '', $url ); 
+	elseif ( 'http' != $scheme )
 		$url = str_replace( 'http://', "{$scheme}://", $url );
 
 	if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
@@ -2061,7 +2065,7 @@
  * @since 3.0.0
  *
  * @param string $path Optional. Path relative to the site url.
- * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', or 'admin'.
+ * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
  * @return string Site url link with optional path appended.
 */
 function network_site_url( $path = '', $scheme = null ) {
@@ -2071,7 +2075,7 @@
 		return site_url($path, $scheme);
 
 	$orig_scheme = $scheme;
-	if ( !in_array($scheme, array('http', 'https')) ) {
+	if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
 		if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
 			$scheme = 'https';
 		elseif ( ('login' == $scheme) && ( force_ssl_admin() ) )
@@ -2082,7 +2086,10 @@
 			$scheme = ( is_ssl() ? 'https' : 'http' );
 	}
 
-	$url = $scheme . '://' . $current_site->domain . $current_site->path;
+	if ( 'relative' == $scheme )
+		$url = $current_site->path;
+	else
+		$url = $scheme . '://' . $current_site->domain . $current_site->path;
 
 	if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
 		$url .= ltrim($path, '/');
@@ -2101,7 +2108,7 @@
  * @since 3.0.0
  *
  * @param  string $path   (optional) Path relative to the home url.
- * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https'.
+ * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
  * @return string Home url link with optional path appended.
 */
 function network_home_url( $path = '', $scheme = null ) {
@@ -2112,10 +2119,13 @@
 
 	$orig_scheme = $scheme;
 
-	if ( !in_array($scheme, array('http', 'https')) )
+	if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
 		$scheme = is_ssl() && !is_admin() ? 'https' : 'http';
 
-	$url = $scheme . '://' . $current_site->domain . $current_site->path;
+	if ( 'relative' == $scheme )
+		$url = $current_site->path;
+	else
+		$url = $scheme . '://' . $current_site->domain . $current_site->path;
 
 	if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
 		$url .= ltrim( $path, '/' );
Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 19859)
+++ wp-includes/media.php	(working copy)
@@ -1096,7 +1096,7 @@
 <script type="text/javascript">
 /* <![CDATA[ */
 	jQuery(document).ready(function($){
-		$.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post_ID ); ?>");
+		$.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post_ID, 'relative' ); ?>");
 	});
 /* ]]> */
 </script>
