redirect – Can’t login to WordPress admin panel after changing domain to use WordPress pages as a fallback from React

Question

we had our WordPress page running on example.com.

But now, we’re developing new React website, which already has some of the webpages ready.
We use Vercel to host that React website.

We want React/Vercel to host specific pages (which are already developed) and serve the wordpress page as a fallback.

E.g.:

React already has page example.com/pageA ready, so we want that URL to be served directly by Vercel/React.

On the other hand, React doesn’t has page example.com/pageB ready, so we want to use WordPress’s page as a fallback. We’ve set routing in our React app and it just asks the fallback domain for the address it missess.

For that reason we’ve created subdomain legacy.example.com which points to old WordPress webpage and redirected our main example.com domain to Vercel. In the case, when user tries to hit example.com/pageB, the Vercel asks WordPress under legacy.example.com/pageB address and response with that page at example.com/pageB.

We’ve had some problems with WordPress as it tried to redirect pages to the same adress (creating redirect loop) but we manage it by adding remove_filter('template_redirect','redirect_canonical');.

But, we still have problem when trying to log in into admin panel. After accesing example.com/wp-admin we’re getting redirected to https://example.com/wp-login.php?redirect_to=https%3A%2F%2Flegacy.example.coml%2Fwp-admin%2F&reauth=1. Trying to log on that page doesn’t work – we’re being redirected to the same page and nothing happens.

How can I solve that issue when loging?

Also – is there a better option than turning off canonical redirects? I’m afraid of some side effects of that. The siteurl and home properties are still set to https://example.com.

0
michalsol 2 months 2022-05-15T11:15:31-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse