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 want to install something different than wordpress under 'mydomain.com/login', but WordPress automatically redirecting this link '/login' to '/wp-login.php'.

Where can I turn off this redirection?

share|improve this question
This question is almost similar to what you are asking!!! stackoverflow.com/questions/1976781/… – sri Feb 18 '14 at 13:33
ok, thanks - I will try this! – marek Feb 18 '14 at 13:41
Please do a bit more search on this site and I am sure you will find a solution for this problem... – sri Feb 18 '14 at 13:41
up vote 3 down vote accepted

If you look at canonical.php you will notice that the wp_redirect_admin_locations function is hooked very late-- at priority 1000. This means that just about any function hooked to redirect_canonical runs before this one. So, conditionally remove wp_redirect_admin_locations from the template_redirect hook.

  function() {
    $requ = untrailingslashit($_SERVER['REQUEST_URI']);
    if (site_url('login','relative') === untrailingslashit( $_SERVER['REQUEST_URI'] )){
      remove_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
share|improve this answer
It's working perfect - thank you! – marek Feb 19 '14 at 8:46

This answer is based on the findings of “login” in permalink redirects to wp-login.php wp3.6

Disable "/login" redirect

As already stated there the relevant code is located at the very end in /wp-includes/canonical.php

You need to remove the default "wp_redirect_admin_locations" and replace it with a slightly modified custom version. Add this to your function.php file.

function custom_wp_redirect_admin_locations() {
    global $wp_rewrite;
    if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) )

    $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() );

    $logins = array(
        home_url( 'wp-login.php', 'relative' )
    if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins ) ) {
        wp_redirect( site_url( 'wp-login.php', 'login' ) );

function remove_default_login_redirect() {
    remove_action('template_redirect', 'wp_redirect_admin_locations', 1000);
    add_action( 'template_redirect', 'custom_wp_redirect_admin_locations', 1000 );


Why this might not even be necessary

Also you should be aware that the redirect only applies if there is nothing else at /login. As soon as e.g. you create a page /login the redirect doesn't apply any more. (See /wp-includes/canonical.php:553 for where this happens.

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.