--- canonical.php~	2017-08-06 23:30:46.000000000 +0200
+++ canonical.php	2017-08-07 00:03:33.000000000 +0200
@@ -71,14 +71,15 @@
 		return;
 	}
 
+	// Notice fixing
+	if ( !isset($original['path']) )
+		$original['path'] = '';
+	if ( !isset($original['query']) )
+		$original['query'] = '';
+
 	$redirect = $original;
 	$redirect_url = false;
 
-	// Notice fixing
-	if ( !isset($redirect['path']) )
-		$redirect['path'] = '';
-	if ( !isset($redirect['query']) )
-		$redirect['query'] = '';
 
 	// If the original URL ended with non-breaking spaces, they were almost
 	// certainly inserted by accident. Let's remove them, so the reader doesn't
@@ -567,7 +568,8 @@
 		if ( ! empty( $parsed_url['port'] ) ) {
 			$url .= ':' . $parsed_url['port'];
 		}
-		$url .= $parsed_url['path'];
+		if ( isset( $parsed_url['path'] ) )
+			$url .= $parsed_url['path'];
 		if ( ! empty( $parsed_url['query'] ) ) {
 			$url .= '?' . $parsed_url['query'];
 		}
