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?
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?
Comments are closed.
If you look at
canonical.php
you will notice that thewp_redirect_admin_locations
function is hooked very late– at priority 1000. This means that just about any function hooked toredirect_canonical
runs before this one. So, conditionally removewp_redirect_admin_locations
from thetemplate_redirect
hook.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.
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.