Fixing a Broken Wordpress Site After Migrating
How to easily fix a broken Wordpress site after updating the site address.
By. Jacob
Edited: 2020-10-27 13:04
When a site breaks after changing the address, it is often because the siteurl option does not match the absolute path of your Wordpress installation.
In order to revert the address changes made to a Wordpress site, we will need to edit the database. I personally find this method very easy, and you can either do it from within PHP or from a terminal.
Another option, if you are not comfortable using SQL, is to try to change it via PHPMyAdmin. You should select the wp_options table, and then change the row where option_name equals siteurl in the database. Change the option_value to the absolute base path of your site installation.
You can also change it simply using this query, after logging in to MySQL:
UPDATE wp_options set option_value='https://example.com/' where option_name='siteurl' and option_name='home';
From within PHP, you would need to execute the above query using mysqli or similar. Simply creating a temporary file to run the query should do the trick. But I recommend doing it from the command line or from phpMyAdmin.
See also: How to Move a Wordpress Website Manually
Note. If Wordpress is installed in a subdirectory instead of the site root, then you will need to make sure to update the siteurl with the correct absolute path for the subdirectory. I.e: https://example.com/some-subdirectory/
If you installed on a subdomain, then you will need to make your query reflect that as well. I.e.: https://mysubdomain.example.com/
I am not even sure why Wordpress makes it possible to change the site address from within the control panel, too many fumbling users break their sites, and then they have to edit the database to fix it. There is no need to change the domain name from the control panel, since it will obviously just break the site.
Tell us what you think: