Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 34188)
+++ wp-includes/link-template.php	(working copy)
@@ -3268,19 +3268,35 @@
  * @global WP_Query $wp_the_query
 */
 function rel_canonical() {
-	if ( !is_singular() )
-		return;
+	$link = false;
+	if ( is_singular() ) {
+		global $wp_the_query;
+		if ( !$id = $wp_the_query->get_queried_object_id() )
+			return;
 
-	global $wp_the_query;
-	if ( !$id = $wp_the_query->get_queried_object_id() )
-		return;
+		$link = get_permalink( $id );
 
-	$link = get_permalink( $id );
+		if ( $page = get_query_var('cpage') )
+			$link = get_comments_pagenum_link( $page );
+	} else if ( is_home() || is_front_page() ) {
+		$link = get_home_url(null, '/');
+	} else if ( is_search() ) {
+		global $wp_the_query;
+		if ( empty( $wp_the_query->query_vars['s'] ) ) {
+			return;
+		}
+		$link = esc_url(
+			add_query_arg(
+				's',
+				$wp_the_query->query_vars['s'],
+				get_home_url(null, '/')
+			)
+		);
+	}
 
-	if ( $page = get_query_var('cpage') )
-		$link = get_comments_pagenum_link( $page );
-
-	echo "<link rel='canonical' href='$link' />\n";
+	if ( $link ) {
+		echo "<link rel='canonical' href='$link' />\n";
+	}
 }
 
 /**
