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: https://develop.svn.wordpress.org/trunk@6115 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2007-09-14 19:41:23 +00:00
parent 3db6ccefb0
commit f372b1dd05
1 changed files with 5 additions and 3 deletions

View File

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