Fixing URL issues after migration of a website from a staging server to live server
There are some common issues which arises when we migrate a WordPress website from one server to another, like from staging to live or from one domain to another domain.
Most of the time the main issue comes due to links and url’s which are still pointing to the old staging server. This will give 404 errors for the links and images.
To fix such issues there are many ways in WordPress and we will explain one of them.
This process will require access to your website database. if you have a cpanel hosting then you will find it under phpMyAdmin . If you have any other setup please get the database access to follow this process.
Steps to debug URL issues of WordPress:-
1. Log into your cPanel interface.
2. Check for database section and select phpMyAdmin tool.
3. It will take you to the main phpMyAdmin page. Check for the database name which is used in your WordPress site.
4. Select the database, then select wp_posts table from the database selected.
5. Now you will find a tab named SQL click on that SQL button and a SQL editor will open below that.
6. Now type these commands and press Go button in the right bottom of this SQL window
UPDATE wp_posts SET post_content=(REPLACE (post_content, 'yourdomain.com','yournewdomain.com'));
and after that run this query –
UPDATE wp_posts SET guid = replace(guid, 'yourdomain.com', 'yournewdomain.com');
Note:- Please note one thing here that there may be different prefix other than ‘ wp_ ‘ for table post, please check if you don’t find the table wp_post.
Example- 01
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.yourOldDomainName.com', 'http://www.yourNewDomainName.com');
UPDATE wp_posts SET guid = replace(guid, 'http://www.yourOldDomainName.com', 'http://www.yourNewDomainName.com');
Great it is done….
7. Check for the links and you will find them all fixed.
So we have fixed all the errors which are coming due to these old url and links.
Happy Coding…