Canonical: Ensure that when permalinks are set to a trailing slash, that robots.txt doesn't.

Fixes #48025.

Props Toro_Unit, joostdevalk, SergeyBiryukov.



git-svn-id: https://develop.svn.wordpress.org/trunk@48153 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock 2020-06-23 23:42:36 +00:00
parent 9eefc4b0d9
commit 7a8d8a3e8a

View File

@ -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'] ) ) {