Index: comment.php
===================================================================
--- comment.php	(revision 8822)
+++ comment.php	(working copy)
@@ -1021,7 +1021,7 @@
  * @param int $timeout_bytes Number of bytes to timeout at. Prevents big file downloads, default is 2048.
  * @return bool|string False on failure, string containing URI on success.
  */
-function discover_pingback_server_uri($url, $timeout_bytes = 2048) {
+function discover_pingback_server_uri($url, $timeout_bytes = 2048, $redirects = 3) {
 	global $wp_version;
 
 	$byte_count = 0;
@@ -1050,6 +1050,29 @@
 	// ob_end_flush();
 	fputs($fp, $request);
 
+	// Determine response code; if we receive a 301, then follow it
+	$line = fgets($fp, 512);
+	preg_match('!^HTTP/(\w|\d)+?\.(\w|\d)+? (?P<code>\d+?) !i', $line, $matches);
+	$response_code = isset($matches['code']) ? (int)$matches['code'] : null;
+	if ( $response_code == 301 ) {
+		if ( $redirects < 1 ) {
+			// Can't follow any more redirects :(
+			return false;
+		}
+
+		// Look for a location header
+		while ( !feof($fp) ) {
+			$line = fgets($fp, 512);
+			if ( trim($line) == '' )
+				break;
+			if ( preg_match('#^location: (.+)$#i', $line, $matches) ) {
+				// Found location header; rinse and repeat
+				$location = trim($matches[1]);
+				return $this->discover_pingback_server_uri($location, $timeout_bytes, $redirects - 1);
+			}
+		}
+	}
+
 	// Let's check for an X-Pingback header first
 	while ( !feof($fp) ) {
 		$line = fgets($fp, 512);
