mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-14 01:24:27 +00:00
Canonical: Move trailing slash handling for robots.txt and sitemaps to a single condition.
Give the unit test a more descriptive name. Follow-up to [48153], [48155]. See #48025. git-svn-id: https://develop.svn.wordpress.org/trunk@48166 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -57,8 +57,8 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_admin() || is_search() || is_preview() || is_trackback()
|
||||
|| is_favicon() || ( $is_IIS && ! iis7_supports_permalinks() )
|
||||
if ( is_admin() || is_search() || is_preview() || is_trackback() || is_favicon()
|
||||
|| ( $is_IIS && ! iis7_supports_permalinks() )
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -655,8 +655,10 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
||||
$redirect['path'] = trailingslashit( $redirect['path'] );
|
||||
}
|
||||
|
||||
// Remove trailing slash for sitemaps requests.
|
||||
if ( ! empty( get_query_var( 'sitemap' ) ) || ! empty( get_query_var( 'sitemap-stylesheet' ) ) ) {
|
||||
// Remove trailing slash for robots.txt or sitemap requests.
|
||||
if ( is_robots()
|
||||
|| ! empty( get_query_var( 'sitemap' ) ) || ! empty( get_query_var( 'sitemap-stylesheet' ) )
|
||||
) {
|
||||
$redirect['path'] = untrailingslashit( $redirect['path'] );
|
||||
}
|
||||
|
||||
@@ -682,11 +684,6 @@ 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'] ) ) {
|
||||
|
||||
Reference in New Issue
Block a user