WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


add_filter('admin_url', 'my_new_admin_url');

function my_new_admin_url()
    return '/login/';


Redirect permanent /wp-admin/ /login/
share|improve this question
I've never seen that admin_url filter usage, do you have a reference? – brasofilo May 23 '12 at 17:38
up vote 4 down vote accepted

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() );
add_action( 'parse_query', 'wpa53048_parse_query' );


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() );
add_action( 'parse_request', 'wpa53048_parse_request' );
share|improve this answer
I understand what you mean and I find this to be a good way of dealing with this redirect but unfortunately it doesn't work. Any ideas if this has any compatibility issues with WP 3.3.2 ? Thanks – thedev May 23 '12 at 18:23
@thedev - my first method seems to depend on the permalink structure, it works if you use date-based permalinks but not postname or a static prefix. i added another, similar method. – Milo May 23 '12 at 18:48
Second solution works great, except one case. When I use the default permalinks with ?p= I receive a 404 error. Any ideea why this is happening ? – thedev May 24 '12 at 19:43
@thedev - With default permalinks you'll get your server's 404 page, since requests for anything not a physical file or directory are no longer being routed through WordPress. In that case you will have to use brasofilo's technique with an .htaccess file. – Milo May 29 '12 at 18:23

I use just this at the top of my .htaccess file:
RewriteRule ^login/?$ /wp-login.php [NC,L]

or the following, case WordPress resides in a folder, and the rule refers to the root:
RewriteRule ^login/?$ /wp/wp-login.php [NC,L]

I've seen [QSA,L] used instead of [NC,L], but don't know the difference...

Reference: http://planetozh.com/blog/2011/01/pretty-login-url-a-simple-rewrite-api-plugin-example/

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.