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
This commit is contained in:
whyisjake 2020-06-23 23:44:09 +00:00
parent 4f69c150b7
commit bb7a531b75
2 changed files with 7 additions and 3 deletions

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

View File

@ -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.