Q:

How to turn off redirection from 'domain.com/login' to 'domain.com/wp-login.php'

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?

A:

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.
add_action(
  'template_redirect', 
  function() {
    $requ = untrailingslashit($_SERVER['REQUEST_URI']);
    if (site_url('login','relative') === $requ ){
      remove_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
    }
  }
);

