Update all sites on WordPress Multisite to https using WP-CLI

Need to update all of your sites on WordPress Multisite from http:// to https://? As it turns out, it’s not easily possible with wp search-replace but you can do it with wp eval-file instead.

Simply download the following http-to-https.php file and run:

wp site list --field=url | xargs -I % wp eval-file http-to-https.php --url=%

Read this for a better explanation of wp site list and xargs. Your output should look something like this:

Updated 'home' to 'https://wp-ms.test'
Updated 'siteurl' to 'https://wp-ms.test'
Success: Options updated for https://wp-ms.test
Updated 'home' to 'https://wp-ms.test/foo'
Updated 'siteurl' to 'https://wp-ms.test/foo'
Success: Options updated for https://wp-ms.test/foo

One Comment

Mike Langone March 28, 2018 Reply

Thank you so much I downloaded the file and added to my wp directory. Ran the command and it successfully updated.

Leave a Reply