Images and links wrong after website move or domain change?
Sometimes it simply happens, that you need to migrate your website from one server to another, or from one domain to another.
Especially when you are changing the web hosting provider due some better conditions, or if you have your own company and you decided to change the name or domain. Migration of the website running on a WordPress content management system seems to be easy for the first sight.
Of course, when it comes to the testing of the website on the new location (domain or server), then it comes. All your links inside the posts, articles, pages, are wrong. Images are wrong, or there are even no images sometimes. You are asking yourself the question how this happened? The answer is simple – because when your website is quite large, it can simply happen. The database remembers the old links, old paths to images. But do not worry, there is always a solution, just follow these simple steps and you can fix this.
First think you what you should do is to login to your web hosting and go to your control panel. There is also a way to do this through the MySQL Workbench software, but I will explain you the solution through the web based control panel that most of the web hosting providers have.
- After login to the web hosting provider, in your control panel find the option “database management” or mostly the web base application “phpMyAdmin”. Click on it and allow the web application to load.
- You should be now now on the main phpMyAdmin page. Find the newly added database of your new website and click on its name from the sidebar on the left side.
- This will open the database and will display a list of the tables. Using the sidebar again, find and click on the wp-posts table.
- Now just look to the top of the screen and you will see several tabs that are across the page. Click on the SQL tab.
- You are now on a MySQL editor screen. Now copy the following bit of MySQL code and paste it into the code area:
UPDATE wp_posts SET post_content=(REPLACE (post_content, ','));
UPDATE wp_posts SET post_content=(REPLACE (post_content, 'oldwebsite.com','newwebsite.com'));
Now you can simply click on the Go button and wait until the code runs. This will change all the URLs for all images in the posts, articles and pages of your website. The old images and links linked to the old domain will be overwritten to the new domain.
As I mentioned above, you can also use the MySQL Workbench software or any other software that you can install directly into your computer. The SQL code should be the same, but of course the look will be different than the web based phpMyAdmin mostly used by web hosting providers.
If you have some other experience, feel free to let me and others know by letting your comment below this article.