How to: Replace Absolute URLs in WordPress Posts Using PHPMyAdmin

30th October 2014

If you’ve moved your WordPress website from one domain to another, one of the associated headaches is changing all of the absolute file paths in your posts and pages. If you’ve inserted an image or a link to another page, they’ll all now be incorrect. One way to fix the problem is to go through each post/page manually updating the URL of every single one of your links and images. BORING. On a big site this is going to take ages, so if you’ve got PHPMyAdmin you can take the sting out of it. Here’s how it’s done:

Log in to your database from PHPMyAdmin. If you don’t know the details or which of your databases you’re using, you’ll find this information in the wp-config.php file in the root of your WordPress installation.

With your database selected, hit the SQL tab. This will allow you to run a SQL query on the database.

We want PHPMyAdmin to go through the posts stored in the database and replace any instances of the old domain URL with the new one. To do that we’re going to use this script, so paste it into the big text box that appears:

NB: You need to make sure the table prefix is right. The standard is wp_ but it make have been changed to something different. You’ll easily be able to tell by looking at the names of your WordPress tables down the left hand side of the screen.

Hit ‘Go’, wait a few seconds and let PHPMyAdmin complete the task in a matter of seconds.

Leave a Reply

I am not exactly a technophobe but due to previous experiences of pressing buttons that I have no business pressing I have shied away from doing thing to update or improve my site. I have called on Jo Cox’s expertise several times and she is always quick, efficient and gets you back on track whilst also calming you down. I can honestly say that there is no one else I would call on in an emergency to sort out problems with my website. I have never had a bad experience with Jo’s services or with Jo as the service provider.

Lisa Bentley