Move WordPress to Another Domain

How to move WordPress to a new domain? Easy.

  1. Copy all WordPress files to a new folder:
    cp -rp /var/www/html/old_domain.com/. /var/www/html/new_domain.com/
    As usual, -rp means Recursive copy including subdirectories and Preserving owner attributes. Note the dot at the end of the old folder – it is required to copy system files like .htaccess which otherwise would be skipped (if you use asterisk instead of dot). Once command is completed, there will be two copies of the same WordPress installation.
  2. Log in to the admin panel using old domain. Navigate to Settings – General. And update two URLs to point them to new rather than old domain. Once you click Save settings, you will be redirected to wp-admin interface of a new domain. You can log in with the same username and password as before, but not right now – complete the next step first.
  3. Remove (or disable) WordPress files from the old location so that it does not access database of WordPress running at a new location.
  4. Check if any additional files contain link(s) to the old domain. For example, sitemap.xml may need to be rebuilt as it contains full links that start with http:// and therefore contain domain name. Can use grep command for this, -r for Recursive (do not forget to navigate for the new folder first):
    cd /var/www/html/new_domain.com/
    grep -r 'old_domain.com' *
  5. Check both front and back end but that should be it – happy blogging!

127 total views, 1 views today