Converting uploads on multisite subdirectory to bedrock

I’m in the process of converting a large vanilla multisite subdirectory install into a bedrock stack.

Migrating the database is straightforward, but I run into errors with the images within each site. And doing a simple search/replace of /wp-content/ to /app/ does not affect all the sites within the network because that doesn’t contain their site url.

So, has anyone figured out a way to take an img url like below:

And programmatically convert it to:

Rather than going through the database and running search/replace for each site within the install? (I’m dealing with 50+ sites here…)

Or, is there a way to keep the subdirectory (e.g./host/) within their Bedrock multisite subdirectory install?

I’m not going to claim to be a Multisite expert (I’m not in any way shape or form), but isn’t a multisite install one single database?

WP-CLI is able to search-replace serialized content in a database, so why would you not be able to run wp search-replace wp-content/ app/ on the entire database?

Be careful. If the users have blogs that have external hotlinks to other wordpress sites this will break them.

The proper solution here is to combine the output of with

This can be done with a loop in a shell script pretty handily. Make sure to test locally first.


thanks! i’ll check this out and report back.

just to reiterate it’s not going from to that i need t o accomplish.

in my bedrock, it seems the /site/ in my url is being removed, by design or my mistake.