Turns out, if you lose access to your domain, it’s a real hassle to switch to a new domain. After a bit of trial and error, I found a solution making use of the developer interface of my browser.
What happened was this: I had my wordpress website set up at my old domain, <old_url>. When <old_url> became unavailable, I linked the container that runs it to my new domain, <new_url>. Visiting that page worked — for the homepage. But I quickly noticed that all links on the page were redirecting to <old_url> which doesn’t exist anymore. To fix that, I had to login to the wp-admin, but that process itself was blocked by redirecting to the old URL.
What worked for me was first navigating to <new_url>/wp-admin.php, the admin login page, directly. From there, the login button (and all others) still redirected to <old_url>. I tried replacing <old_url>⇒<new_url> in the HTML inspector, but was still redirected to non-existing pages. The solution was running the following code in the developer options’ console:
document.getElementById('loginform').action = 'https://<new_url>/wp-login.php';
document.querySelector('input[name="redirect_to"]').value = 'https://<new_url>/wp-admin/';
After that, I continued normally with the login process. I had to change the URL I was redirected to a few times, in the URL bar directly or in the Developer options HTML inspector, but the above code helped with the largest problem – logging in in the first place.
Once that was fixed, I just had to change the URL in the wp-admin settings, at →Settings→General→WordPress Address (URL) and →Settings→General→Site Address (URL). Suddenly, the rest of the page usable again. I had to manually fix a few navigation links afterwards, but this was the biggest hurdle in getting this page back up and running.
I hope if someone else runs in to similar problems, this may help.
Leave a Reply