I copied my WP content to a new install on a different server, so now my uploaded PDF documents have the old URL. Is there a simple way to fix that in all my posts at once, perhaps with SQL or some plugin ?
Leave a Reply
You must be logged in to post a comment.
Use the script found here:
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Because WordPress serializes some urls in option and meta tables a simple replace won’t do.
A siple replace will break your data.
This script will preserve your data and replace it with a new url.
I use it al least twice a month.
I have always used the Velvet Blues plugin and it has worked great for me. I couldn’t say though how it may or may not handle serialized data. The “easy” factor is pretty hard to beat though.
Go back to the old install. After you exported the SQL database, open it up in any text editor and do a “search and replace”, taking your old url and replacing it with your new url. So if I’m going from
http://localhost:8888/testsite
tohttp://testsite.com
, I need to a search and replace:http://localhost:8888/testsite
http://testsite.com
Make sure you leave off the
/
at the end as you may miss a few URLs when you do your replacing.Now just import this new database into the new install.