Migrating WordPress from Hosting A to Hosting B

Introduction

Migrating WordPress from one hosting environment to another might seem like a formidable task, but armed with the right knowledge and tools, it’s a process you can manage on your own. We concede that it can sometimes be a sweaty endeavour, especially with older websites.

This article will guide you through the entire process of migration step by step, including how to back up your FTP and database files, transfer data between hosts, and configure your site on the new hosting. Migration can introduce a variety of variables, and we will address these and how to tackle them.

Before We Begin

Before initiating the migration, it is crucial to review and compare the technical specifications of both hosts (A and B). Pay special attention to:

  • PHP version
  • PHP memory limit
  • Availability and version of MySQL
  • .htaccess support for Apache or equivalent for NGINX
  • PHP configuration (e.g., max_execution_time)

Significant differences between the hosts may require you to make additional adjustments to your WordPress installation or its configuration. This is particularly true for older websites, which may have parameters incompatible with the default settings of hosting B.

Step 1: Back up your WordPress files

  1. Connect to the FTP/SFTP server of Hosting A: Utilise an FTP client such as Total Commander or FileZilla to connect to your existing hosting.
  2. Download all WordPress files: Select the root directory of WordPress (usually [public_html], [www], [domain-name.cz] or similar) and download all files and directories to your local computer.

Step 2: Back up your MySQL database

  1. Access phpMyAdmin on Hosting A: Log into phpMyAdmin to manage your MySQL database.
  2. Export your database: Select your WordPress database and use the “Export” function. We recommend using the “Quick” method and the “SQL” format for the export.
  3. Download the exported file: Save the exported database in .sql format to your local computer.

Step 3: Preparing the new hosting (Hosting B)

  1. Create a MySQL database: Log into your new hosting and create a new MySQL database, user, and assign full rights to the database.
  2. Create a new FTP account: Similarly to the FTP setup, create a new space for your files. For connecting to your new FTP account, you will require the server (host), username, and password.
  3. Record the details: Note down the database name, username, and password; you will need these later along with the FTP details.

 

Step 4: Import Files and Database to Hosting B

  1. Upload WordPress Files: Connect via FTP/SFTP to the new hosting and upload all the files you previously downloaded from Hosting A into the root directory for your domain.
  2. Import Database: Log into phpMyAdmin on Hosting B, select the newly created database, and use the “Import” function to upload the .sql file you exported from Hosting A.

Step 5: Edit wp-config.php

  1. Modify the wp-config.php File: After uploading the files to the new hosting, open the wp-config.php file in a text editor. Modify the following details to match the new environment:
  2. DB_NAME – the name of the new database on Hosting B
  3. DB_USER – the username for database access
  4. DB_PASSWORD – the password for database access
  5. DB_HOST – the hostname for the MySQL server, usually ‘localhost’, although this can vary depending on the hosting
  6. Save and Close the File: After making the changes, save the file and upload it back to the server via FTP/SFTP.

Step 6: Update URLs

If your website’s domain name or path changes, you will need to update the URLs in the database. URLs are registered not only by subpages but also by various files, media, and documents. This can be accomplished in several ways:

  1. Using an SQL Query in phpMyAdmin: Execute the following SQL queries on your new database to update the URLs:

sqlCopy code

UPDATE wp_options SET option_value = replace(option_value, ‘http://www.old-domain.com’, ‘http://www.new-domain.com) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

UPDATE wp_posts SET guid = replace(guid, http://www.old-domain.com’,’http://www.new-domain.com’);

UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.old-domain.com’, ‘http://www.new-domain.com’);

UPDATE wp_postmeta SET meta_value = replace(meta_value,http://www.old-domain.com’,’http://www.new-domain.com’);

Change ‘http://www.old-domain.com’ to the address of your old site and ‘http://www.new-domain.com’ to the address of your new site.

  • Using a WordPress Plugin: If you are not comfortable with SQL, no worries! There is a WordPress plugin available, such as “Better Search Replace“, which enables you to bulk update URLs through the WordPress admin interface.

Step 7: Testing

Once the migration is complete, it is crucial to conduct thorough testing of your website:

  1. Test All Pages and Posts: Ensure that all pages and posts load correctly and contain no broken links.
  2. Check Form Functionality: Test all forms, including contact and login forms, to ensure they are working properly.
  3. Verify Multimedia: Confirm that all images, videos, and other multimedia content load correctly.
  4. Assess Loading Speed: Utilise tools such as Google PageSpeed Insights or GTmetrix to check the loading speed of your site on the new hosting.

Step 8: Redirect the Domain

After you have successfully transferred your files and database, and have configured WordPress on the new hosting, the final step involves updating your domain settings to point to the new Hosting B. Specifically, this involves updating the DNS records of your domain. This process may include changing the A records or NS records at your domain registrar.

8.1 Changing DNS Records

  1. Access the Domain Registrar: Log into your account at the domain registrar where your domain is registered.
  2. Locate DNS Management: Select the domain you wish to redirect and locate the section for managing DNS records.
  3. Update DNS Records: Change the DNS records to reflect the IP address or the server name (NS records) provided by your new hosting B. Typically, you will update the A record for the main domain and the www subdomain, and possibly other subdomains as necessary.

8.2 Waiting for DNS Propagation

After changing the DNS records, it can take anywhere from a few hours to 48 hours for the changes to propagate across the Internet. During this period, your website may intermittently point to the old or new hosting. This process is known as DNS propagation.

8.3 Checking Website Functionality

Once DNS propagation is complete, thoroughly check the functionality of your website on the new hosting. Ensure everything is operating correctly, including links, forms, plugin functionality, and themes. It is also advisable to perform a test of the page loading speed.

Conclusion

Migrating WordPress between hosts requires meticulous planning and attention to detail, but it is a task that can be successfully accomplished with the right knowledge and tools. It is crucial to meticulously follow the steps, ensure backups are taken, and verify the functionality of every part of your website post-migration. Once you have successfully redirected your domain and confirmed that everything is functioning correctly, you can begin to fully utilise your new hosting environment. Remember to inform your users about potential short-term disruptions during the DNS migration and propagation.

Should you require assistance with your WordPress migration, do not hesitate to contact us. We will get in touch within 24 hours to collaboratively ensure a safe transfer of your domain and facilitate a smooth technical transition from an SEO standpoint.