Skip to content

Cookie settings

Choose which kinds of cookies you allow. You can change your choice at any time via Cookie settings at the bottom of every page. Privacy statement

Necessary

Always on

Needed to log in, keep your cart and remember your choices. These are always on.

Which cookies?
  • weboke_sessie, weboke_klant, weboke_remember: your session and staying logged in
  • weboke_basket: your cart
  • wkBtwIncl: showing prices with or without VAT
  • wok_cookies: your cookie choice, 12 months

Measures which ad leads to a visit or order, so we do not pay for ads that do nothing.

Which cookies?
  • Google Ads via Google Tag Manager (_gcl_au, _gcl_aw), up to 90 days
  • OpenAI Ads, ads in ChatGPT
  • wok_aff: which partner referred you to us (affiliate programme), 60 days

4.6

Country and language

Each country has its own site, with prices and VAT for that country.

View

Migrating a WordPress website

Module 9: Email, search visibility, GDPR, maintenance and migrating · Reading time: 10 minutes

Learning goal: After this lesson you can migrate a WordPress website to different hosting or a different domain without downtime.

Key concepts: migrating to different hosting, migrating to a different domain, installer import, migration plugin, migrating by hand, search and replace, testing before the DNS switch, hosts file, TTL, content freeze, final sync, checks after the switch, change of address in Search Console

Two kinds of migration

There are two kinds of migration, and they are different:

  1. To different hosting, same domain. The website moves from server A to server B; the address stays https://example.com. The DNS changes at the end. Nothing in the database needs to change.
  2. To a different domain. The website moves from example.com to example.net (on the same or different hosting). All addresses in the database change, and you have to redirect the old domain.

Sometimes you do both at once. If so, it's best to split them: first migrate to the new hosting, and only then change the domain. That way, if something goes wrong, you know which step caused it.

And don't forget what sits alongside WordPress: email on the domain, DNS records, cron jobs, other websites in the same package. They don't migrate automatically (DNS course lesson 6.3).

Three ways to transfer the website

MethodHowCaution
Installer importMany installers (Installatron, Softaculous) can fetch a website from another server using the FTP or SFTP details of the old hostingQuick, and the website then appears straight away in your installer (lesson 2.2)
Migration pluginA plugin creates a package (files and database) on the old website and places it on the new one, often converting the addresses as wellSome free versions have a maximum size; large uploads can run into timeouts
By handCopy the files (SFTP or zip), export and import the database, edit wp-config.php, and with a new domain, search and replaceMost work, but you see every step and it always works

By hand, it works like this:

  1. Files: download the entire web directory (or make a zip of it via File Manager) and put it in the web directory on the new hosting.
  2. Database: export it on the old hosting (phpMyAdmin or wp db export), create an empty database with its own user on the new hosting (lesson 2.3) and import it (lesson 8.2).
  3. wp-config.php: enter the new database name, user, password and host. Check the table prefix.
  4. New domain? First make a backup of the database (or use the export from step 2). Then search and replace the addresses with a tool that understands serialised data (lesson 3.2): first the trial run with --dry-run, then the real one. --skip-columns=guid leaves the permanent identifiers of Posts alone, and without --all-tables WP-CLI sticks to the WordPress tables.
wp search-replace 'https://example.com' 'https://example.net' --skip-columns=guid --dry-run
wp search-replace 'https://example.com' 'https://example.net' --skip-columns=guid
  1. Certificate on the new hosting (as soon as the DNS points there, or earlier if the host supports it).

Some hosts will migrate your website for you, free or for a fee; WebOké offers this too. If so, ask which of the steps in this lesson they carry out and which you need to check yourself.

Testing before the DNS switch

The key principle of a migration without downtime: the new website already works before anyone goes to it. You test it on the new hosting while the DNS still points to the old one. Two ways (lesson 2.1):

  • The hosts file on your own computer: add the IP address of the new server next to your domain. Only your computer will then go to the new website. The certificate may not be there yet; accept the warning for this test only.
  • A test address or preview from your new host, which shows your website under the real domain without changing the DNS (at WebOké: "Test your website before migration").

Work through the checklist from lesson 8.2: Pages, images, logging in, forms, shop, permalinks.

Planning the switch

A few days before:

  • Lower the TTL of the records you're going to change (A, AAAA, www) to, for example, 300 seconds, so the switch is quickly visible everywhere later (DNS course lesson 6.1). Do this at least as long beforehand as the old TTL.
  • Make a backup of the old website (lesson 8.1) and store it outside both hosts.
  • Prepare the email if that's migrating too: create mailboxes, transfer email, have the MX records ready (DNS course lesson 6.3).

On the day of the switch:

  1. Content freeze: from now on, nothing changes on the old website. For an online shop: pick a quiet moment and briefly put the shop into maintenance mode, otherwise orders will come in on the old website and you'll lose them.
  2. Final sync: transfer the database (and new uploads) from the old website to the new one once more, so everything from the last few days is included.
  3. Switch the DNS: A and AAAA records (and www) to the new IP address. Remove any old AAAA record (lesson 2.1).
  4. Request a certificate on the new hosting as soon as the DNS points there.
  5. Check with this lesson's exercise and the checklist.

Afterwards:

  • Keep the old hosting for a few more days (with the website in maintenance mode or read-only), for visitors who still have the old address cached, and as a fallback.
  • Check permalinks (save once at Settings > Permalinks if Pages return a 404), cache (clear it), cron jobs and WP-Cron (lesson 6.3), and email sent from the website (lesson 9.1: SPF must now include the new server).
  • Raise the TTL again.
  • Only after a week or two: cancel the old hosting, after downloading one last backup.

With a new domain: redirecting

If you migrate to a different domain, the old domain must stay in place and redirect: every old address with a 301 to the same path on the new domain (https://example.com/contact/ to https://example.net/contact/), not everything to the homepage. That way you keep visitors from old links and your position in search engines (lesson 9.2).

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^(.*)$ https://example.net/$1 [R=301,L]

Keep the old domain (with a certificate on it) for years. Report the migration in Google Search Console using the change of address tool, and submit the new sitemap.

Summary

  • Migrating to different hosting (same domain) and to a different domain are separate jobs; split them if you do both.
  • Transfer the website with an installer import, a migration plugin or by hand (files, database, wp-config.php, and with a new domain, search and replace).
  • Test the new website before the DNS switch via the hosts file or a test address.
  • Lower the TTL in advance, hold a content freeze, do a final sync, switch the DNS and check permalinks, cache, cron and email.
  • With a new domain: every old address with a 301 to the same path on the new domain, and a change of address in Search Console.

Quiz

1. Why do you test the new website before switching the DNS?



2. Why do you lower the TTL a few days before the switch?



3. You're migrating an online shop. Between transferring the database (Monday) and the DNS switch (Thursday), orders come in on the old website. What do you do?



4. You're migrating from example.com to example.net. What's the best way to redirect the old domain?



Exercise

Exercise A9.5: Did the migration succeed? After a migration, enter your domain, the IP address (or server name) of the new hosting, and with a domain change, the old domain as well. The program checks: do the bare domain and www (A and AAAA) point to the new server, is the certificate valid for both names, does the website's REST link point to the correct domain (siteurl converted properly), does the old domain no longer appear in the links and resources of the homepage, and does the old domain (if entered) redirect with a 301 to the same path on the new one?

Exercise A9.5: Did the migration succeed?




What you enter and what we find isn't stored. Your browser remembers your answers and whether you've passed the exercise. If you're signed in, we only save that you got the exercise (almost) right in My courses; you can delete that there too.

Exercise D9.5: Your migration plan. Write a plan for migrating your own website (even if you're not planning to right now): which kind of migration, which transfer method, what needs to come along besides WordPress (email, DNS records, cron jobs), how you'll test before the switch, the timeline (days before, the day itself, the days after) with who does each step, and how you can roll back if it goes wrong. Tick the box to confirm you've looked up the current TTL of your A record, and note it down.

Exercise D9.5: Your migration plan

You do this exercise yourself; no one checks it. Tick off what you've done and mark the exercise as done.



Your ticks and notes only stay in this browser; we don't send them anywhere. If you're signed in, we only save in My courses that you've done the exercise.

Further reading

These articles describe the steps in WebOké's panels; other panels work in a similar way.

One moment…

Set up your domains

For each domain, arrange the nameservers, the link to your hosting and who becomes the owner.

Loading your domains…