Fixing broken images after moving WordPress

2015 EDIT: This applies only if you’ve moved your WordPress installation from one folder in your system to another.  If you’re actually migrating to another host (like from your own installation at to a managed installation at ) use the export and import feature instead. I’ll write about troubleshooting that in a new post, but you can also find info here and  here.

This advice applies to individual installations that have been moved to  a different directory on the server. In my case, I had moved my installation out of the “ideablog” directory and into my web root.  It’s really just a simple MySQL Find and Replace, but here you go.

A few days after moving this blog to a different folder, I realized all of my older posts had broken images. Luckily, the fix was a relatively easy find-and-replace in my favorite little MySQL client. Or even my unfavorite client. I used phpMyAdmin, and after making a backup of my database, it went something like this:

UPDATE `wp_posts` SET post_content = REPLACE( post_content, '', '' )

So, for example, if you blog was at and you’ve moved it to, and now you want to fix the broken image links, you would back up your database and run a query like this:

UPDATE `wp_posts` SET post_content = REPLACE( post_content, '', '' )

It’s just important to be sure to use enough of the old url that you’ll avoid replacing the wrong things. You wouldn’t want to replace ALL instances of the word nyan with ponycorn, right?

I hope that helps!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s