[wp-trac] [WordPress Trac] #19607: home/wp-admin and home/wp-login.php should redirect when home != siteurl
WordPress Trac
wp-trac at lists.automattic.com
Wed Feb 8 18:48:39 UTC 2012
#19607: home/wp-admin and home/wp-login.php should redirect when home != siteurl
-------------------------+-----------------------
Reporter: nacin | Owner: nacin
Type: enhancement | Status: reopened
Priority: normal | Milestone: 3.4
Component: Canonical | Version:
Severity: normal | Resolution:
Keywords: has-patch |
-------------------------+-----------------------
Comment (by nacin):
Something like:
{{{
add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
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' ),
);
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' ),
);
if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ),
$logins ) ) {
wp_redirect( site_url( 'wp-login.php', 'login' ) );
exit;
}
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19607#comment:10>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list