Ever needed to move your WordPress blog to a new URL, perhaps the site is moving or you are trying to create a development site? Perhaps you have the development site finished and want to move it to it’s final URL?
But then the pain comes…you move the files to the new location, and everything breaks. Links are still pointing to the old URL, you can’t login to the WP-Admin cause it’s redirecting you to the old URL, so you start hacking away at the database changing entries for the new location, right?
Wrong. A little surprise hidden within WordPress is a tag to set WordPress in “RELOCATE” mode, meaning that it will work to rediscover it’s base URL.
Step 1 – Edit wp-config.php
Before moving any files, place this bit of code in wp-config.php:
define('RELOCATE',true); // We're on the move!
Step 2 – Move files to new destination
Whether that be via FTP, SSH, SFTP, etc., now is when you make the move.
Step 3 – Login to WP-Admin
Login to your WordPress Admin via www.thenewurl.com/wp-login.php and confirm that it has successfully picked up the new address location.
Step 4 – Disable RELOCATE mode
That line we put in wp-config.php on Step 1? Take that out, you’re done!
Note: This doesn’t update hard coded links or perhaps image references in your blog posts, so there may still be some leg work to be done. However, you could use a plugin like Search Regex to finish that final adjustment!Find this useful? Take just a moment and give a $1. Thanks!