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.

I recently hired Jo to give me some basic HTML and website editing training. I learnt so much in one hour, and she really demonstrated her knowledge, without jargon, and demystified some of the magic of web programming. I would recommend Jo to anyone who needs to brush up on their HTML knowledge, but I would also hire her for larger projects. She was a pleasure to work with and I look forward to working with her again in the future.

Ruth Holroyd