Remap URLs from Relative to Absolute

WP CLI is a great tool for performing common admin and maintenance tasks on a WordPress install. It has a large range of commands that among other things allow you to install plugins, regenerate thumbnails, and in your case, perform a search and replace on the database.

When migrating from dev to production I’d normally run the following command to update URLs in the database:

wp search-replace '//dev.example.com/' '//www.example.com/'

With your existing URL structure you’ll probably need to include the href="https://wordpress.stackexchange.com/questions/276781/ in the search and replace string like so:

wp search-replace"href="https://wordpress.stackexchange.com/" 'href="http://example.com/'

error code: 523