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.

Jo has been looking after my website for a couple of years now. She has just completed another refresh of the site for me, tidying up a few pages and installed a fantastic new booking system that has made a huge improvement to the functionality of the site. I’m really pleased with the result, and the website looks great. I can highly recommend Jo for all your website needs.

(Andrew Tee (Get More Adventure))