Switching URLs in WordPress

Update 2023: Now I use Better Search Replace plugin by WP Engine which makes replacing the site domain in the database even easier and should work anywhere you host your site. Interconnect’s Search and Replace script was blocked on Flywheel the last time I tried it.

When moving sites from development to production, one important part of the move is changing the domain name WordPress recognizes and throughout all the content. Unfortunately in WordPress, there isn’t one place in the administration tool to change the website domain name everywhere, despite the ‘WordPress address’ and ‘Site address’ options in General Settings. These settings miss all internal links throughout content stored in the database.

To replace all URLs stored in the database, I use interconnect/it’s Search and Replace Script in PHP. Follow their instructions and be sure to delete the file from your new site after the URL switch is complete. This script replaces and fixes urls within serialized data, which is important for WordPress sites.