Roots Discourse

Migrating old site to bedrock - media upload path problem

I am setting up a bedrock install of an existing site. I used WP DB Migrate Pro to copy the database and all media. Went smoothly except now all the images inside posts are pointing to the old media upload location. e.g.: http://main-site.dev/wp-content/uploads/2015/08/test.jpg instead of http://main-site.dev/app/uploads/2015/08/test.jpg I can go into each post, edit an image, save it and then it is fine. I could probably also add this to the find/replace of WP Migrate DB. I was just wondering if there is a better/cleaner/easier way to regenerate the media URLs.

If you have wp cli installed you can run: wp search-replace /wp-content/ /app/

You should also setup a 301 redirect for that same URL pair (from /wp-content/ to /app/).

1 Like

If You have WP DB Migrate pro, then by all means best way is to use find/replace. I personally use wp-cli search replace for that :smile: as I am mostly accustomed to it.

Alright thanks. Easy enough, just wanted to be sure.

Any future person can try this too:

I had this issue, the old database has:

upload_path: wp-content/uploads
upload_url_path: https:example/wp-content/uploads

I check on another Bedrock installation and found that both of these fields are empty. Once I removed these values from these fields the media upload worked find.