Allow admin login at /admin

I am interested in:

  1. how can we change the default login url /wp-admin to /login
  2. how can we add another url for login so that both /wp-admin and /login would work

I tried to use a custom filter and .htaccess as in the following example but without success.

Read More

functions.php

add_filter('admin_url', 'my_new_admin_url');

function my_new_admin_url()
{
    return '/login/';
}

.htaccess

Redirect permanent /wp-admin/ /login/

Related posts

Leave a Reply

2 comments

  1. another option – redirect /admin/ to wp-login.php with a parse_query action hook:

    function wpa53048_parse_query( $query ){
        if( $query->query_vars['pagename'] == 'admin' ):
            wp_redirect( wp_login_url() );
            exit;
        endif;
    }
    add_action( 'parse_query', 'wpa53048_parse_query' );
    

    EDIT

    Well the above apparently only works with certain permalink structures. Here’s another method hooked to parse_request:

    function wpa53048_parse_request( $query ){
        if( $query->request == 'admin' ):
            wp_redirect( wp_login_url() );
            exit;
        endif;
    }
    add_action( 'parse_request', 'wpa53048_parse_request' );