How do you seamlessly switch hosting?

Put old host in read-only mode

  1. Go to WP Admin -> Settings -> Discussion and check “Users must be registered and logged in to comment”
  2. Disable authentication:

Create a PHP file inside the wp-content/mu-plugins folder, with the following content:

<?php
function wp_get_current_user() {
    return new WP_User(-1);
}

This will prevent all logged-in users from leaving comments or creating posts on the old host.

Copy files and database to new host

I used FTP for transfering files and phpMyAdmin for exporting/importing the DB.

Handle DNS

  1. Point your domain to the new host’s IP address.
  2. Wait for propagation to take place.

Once the new DNS settings have propagated fully, you can nuke the old host.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)