RazorSPoint
RazorSPoint

Correct urls in WordPress after moving the domain

Update URLs in the MySql Database after moving your Wordpress Website.

Sebastian SchützeSebastian Schütze

Some days ago I finally could set up my new WordPress theme. I also changed the blog URL from the subdomain http://blog.razorstudio.de to https://www.razorspoint.com. With that, I had to change the base URL in the WordPress settings. That was an easy job. But then I came across the problem that most of the image URLs were broken. The problem was that they still pointed to my old domain.

Broken image urls cause the image not to load.

Broken image URLs cause the image not to load.

Check the MySql Database

So what should we do now? I figured I need to update the post content. To do that you should go to your database admin tool. In mine and generally most cases this will be „PhpMyAdmin“. So if you open that tool and choose your WordPress database you can make a search query how much of your content is affected. You can get a good overview if you navigate to the „Search“ tab of PhPMyAdmin and search for part of your old URL surrounded by ‚%‘ (wildcard placeholder). The only other thing you need to mark is your WordPress post table „wp_posts“ in the tables field.

Searching in the MySQL Table (PhpMyAdmin) for table entries which still have the old URL.

After you hit search you will see how much content is affected. In my case, it was nearly 200 entries. Not so much but I haven’t written that much in the last couple of… Uhm YEARS. 😉

But in the next image, you can see that the content still points to the old URL „blog.razorstudio.de“. So let’s change that!

One of the results still show the old url.

One of the results still shows the old URL.

 

The MySql Query to correct the broken URLs in WordPress

The query we will need is the following:

with that query  every old URL with the new one is replaced. Just make sure you put in your URLs and really make sure that the new URL is spelled correctly. You don’t want to change the old wrong URL into a new wrong URL. 😉

The pasted MySql query to change the urls.

The posted MySql query to change the URLs.

As you can see (if you can ready german 😉 ) 183 entries have been edited and successfully changed.

183 database entries where changed on my posts.

183 database entries were changed on my posts.

And Voila all images are corrected.

Urls to the images are correct now.

URLs to the images are correct now.

Just be aware that there could be more tables in your database. If you want to check if there are more entries in other parts of your WordPress database, then have a look here:

How to Move WordPress Blog to New Domain or Location

 

<p>Sebastian Schütze is working as a Senior SharePoint Developer since 2017 at Schindler Digital Business and from 2013-2017 as a SharePoint Consultant at Fritz & Macziol. Beforehand he also worked as a trainer for ASP.NET web development in the Microsoft Student Partner Program. His passion is dedicated to Microsoft technologies.</p>

Comments 0
There are currently no comments.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close