In case of 404, redirect /login, /dashboard, /admin to corresponding WP equivalents. fixes #19607.

git-svn-id: http://svn.automattic.com/wordpress/trunk@19880 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-02-08 20:11:52 +00:00
parent a0ec80fff3
commit d06722b8ac
1 changed files with 30 additions and 7 deletions

View File

@ -92,13 +92,6 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
}
}
if ( ! $redirect_url && get_option( 'home' ) != get_option( 'siteurl' ) ) {
if ( trailingslashit( $original['path'] ) == home_url( 'wp-admin/', 'relative' ) )
$redirect_url = admin_url();
elseif ( $original['path'] == home_url( 'wp-login.php', 'relative' ) )
$redirect_url = site_url( 'wp-login.php', 'login' );
}
if ( ! $redirect_url )
$redirect_url = redirect_guess_404_permalink( $requested_url );
@ -472,3 +465,33 @@ function redirect_guess_404_permalink( $current_url = '' ) {
}
add_action('template_redirect', 'redirect_canonical');
function wp_redirect_admin_locations() {
global $wp_rewrite;
if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) )
return;
$admins = array(
home_url( 'wp-admin', 'relative' ),
home_url( 'dashboard', 'relative' ),
home_url( 'admin', 'relative' ),
site_url( 'dashboard', 'relative' ),
site_url( 'admin', 'relative' ),
);
if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) {
wp_redirect( admin_url() );
exit;
}
$logins = array(
home_url( 'wp-login.php', 'relative' ),
home_url( 'login', 'relative' ),
site_url( 'login', 'relative' ),
);
if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins ) ) {
wp_redirect( site_url( 'wp-login.php', 'login' ) );
exit;
}
}
add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );