From 8a6802ef004927fbc256a57e903d8bf165bdc19d Mon Sep 17 00:00:00 2001 From: markjaquith Date: Fri, 14 Sep 2007 19:41:23 +0000 Subject: [PATCH] Canonical fixes: Allow Pages to have /page/x/. Always trailing slash home when it is not paged. Strip extra trailing slashes off of /page/x/// git-svn-id: http://svn.automattic.com/wordpress/trunk@6115 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/canonical.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 9b458dee9a..b88efc49fc 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -72,14 +72,14 @@ function redirect_canonical($requested_url=NULL, $do_redirect=true) { if ( !$redirect_url ) $redirect_url = $requested_url; $paged_redirect = @parse_url($redirect_url); - $paged_redirect['path'] = preg_replace('|/page/[0-9]+?/?$|', '/', $paged_redirect['path']); // strip off any existing paging + $paged_redirect['path'] = preg_replace('|/page/[0-9]+?(/+)?$|', '/', $paged_redirect['path']); // strip off any existing paging $paged_redirect['path'] = preg_replace('|/index.php/?$|', '/', $paged_redirect['path']); // strip off trailing /index.php/ - if ( $paged > 1 && !is_singular() ) { + if ( $paged > 1 && !is_single() ) { $paged_redirect['path'] = trailingslashit($paged_redirect['path']); if ( $wp_rewrite->using_index_permalinks() && strpos($paged_redirect['path'], '/index.php/') === false ) $paged_redirect['path'] .= 'index.php/'; $paged_redirect['path'] .= user_trailingslashit("page/$paged", 'paged'); - } elseif ( !is_home() && !is_singular() ){ + } elseif ( !is_home() && !is_single() ){ $paged_redirect['path'] = user_trailingslashit($paged_redirect['path'], 'paged'); } $redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path']; @@ -132,6 +132,8 @@ function redirect_canonical($requested_url=NULL, $do_redirect=true) { } } $redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type); + } elseif ( is_home() ) { + $redirect['path'] = trailingslashit($redirect['path']); } // Always trailing slash the 'home' URL