a redirect_to from the wordpress software isn’t working
domain.com/wp-login.php?redirect_to=https%3A%2F%2Fforums.domain.com%2F
which should then return to the sub directory of forums
However it simply goes to domain.com/wp-admin
I have disabled all plugins, tried a different browser, tried both an admin and regular user.
I have also upgraded to 6.3.1 – tried on both this and the old version.
I run cloudfare, but also disabled this.
I also have a redirection plugin installed – but this works fine (also disabled to check a conflict)
I am at a loss to figure out why this is failing
2
Answers
The above didn't work.
instead
should work.
The difference being the word array missing in the first example.
If redirect_to is passed via url request, WordPress uses the function wp_safe_redirect (not wp_redirect) which checks for allowed hosts for security reasons. As forums.domain.com is different from domain.com and is not in the list of allowed hosts, the redirect defaults to admin_url().
To make the redirect work, you should add forums.domain.com to the list of allowed hosts (e.g. inside your functions.php) using a filter function: