From bb7a531b7548eda02826dde7427b366b496783ff Mon Sep 17 00:00:00 2001 From: whyisjake Date: Tue, 23 Jun 2020 23:44:09 +0000 Subject: [PATCH] Canonical: Ensure that when permalinks are set to a trailing slash, that robots.txt doesn't. Fixes #48025. Props Toro_Unit, joostdevalk, SergeyBiryukov. Built from https://develop.svn.wordpress.org/trunk@48153 git-svn-id: http://core.svn.wordpress.org/trunk@47922 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/canonical.php | 8 ++++++-- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index befe58e684..a799c5c2d3 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -58,8 +58,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { } if ( is_admin() || is_search() || is_preview() || is_trackback() - || is_robots() || is_favicon() - || ( $is_IIS && ! iis7_supports_permalinks() ) + || is_favicon() || ( $is_IIS && ! iis7_supports_permalinks() ) ) { return; } @@ -683,6 +682,11 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $redirect['host'] = $original['host']; } + // Even if the permalink structure ends with a slash, remove slash robots.txt. + if ( is_robots() ) { + $redirect['path'] = untrailingslashit( $redirect['path'] ); + } + $compare_original = array( $original['host'], $original['path'] ); if ( ! empty( $original['port'] ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 530f386594..c4ccbd5043 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-48152'; +$wp_version = '5.5-alpha-48153'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.