We have a domain which is https://developer.site.com served on one server. Then, we have https://developer.site.com/blog which goes to an entirely different location, serving up a wordpress site. (Technically speaking this is called a 'forward rewrite.')
The front-end and most of the admin are acting fine, however there are a couple of places where it is redirecting back to a 404 on the other server.
For example:
https://developer.site.com/blog/wp-login.php?action=rp&key=t34T4akjihAB231sCwgJU9TU&login=abcde
This URL redirects to the 404, excluding the /blog part from the URL.
When tracking the site, it appears it goes go to the right url, but then immediately wordpress is sending it to the 404 page, so it's something wrong with wordpress. We have checked and double-checked the domain masking and we're convinced it's all good.
I have found wp_safe_redirect() in the code a few times. This might be the culprit? Maybe something is pulling up the wrong directory structure, leaving off the /blog part internally, but I don't see why that should matter.
You can filter redirects here is what i think will work for you
More Info about here https://codex.wordpress.org/Function_Reference/wp_safe_redirect
Copy the following code in your text editor CHANGE THE EXAMPLE HOST DOMAIN LINES and save it as allowed-host-plugin.php put in a folder called allowed-host-plugin and upload it to your plugins directory go to you plugins in admin and activate. That's it should work.