Change WordPress Website URL (from wp-config.php)
Sometimes you need to change your website’s url to a new url, it could be for many reasons but we won’t dwell on that right now. The thing is, that sometimes you can find yourself ‘stuck’ outside of your /wp-admin/ area and that’s, how to say, sucks.
One way to do that is to add these 2 lines in wp-config.php:
define('WP_SITEURL', 'http://yournewurl.com'); define('WP_HOME', 'http://yournewurl.com');
This code will override the website url that’s defined in your site’s database and make you be able to log into to your admin area again.
Important – after doing that, go to “Settings -> Permalinks” and just click ‘Save’ on the bottom of the settings. That will update all the encoded posts/pages url to the new one.
Good luck!