WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
up vote 0 down vote accepted

Use the script found here:


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.

share|improve this answer
Worked for me, thx! – drake035 Sep 13 '12 at 19:46

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.

share|improve this answer

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 to http://testsite.com, I need to a search and replace:

  • Search: http://localhost:8888/testsite
  • Replace: 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.

share|improve this answer
This is a bad way to do it. WordPress serialises some data. If you do this it will break that data. – janw Sep 13 '12 at 13:24
Sure. Never had an issue doing it this way and I've done it for sites with 1000+ posts/comments etc. so thought I'd mention it. – bryceadams Sep 13 '12 at 15:04
This works for the case where you're modifying links in posts, but not if you're trying to modify data that might have been saved by a plugin. Better to use a search/replace plugin to do it. – Otto Sep 13 '12 at 19:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.