How to move WordPress to a new domain? Easy.
- Copy all WordPress files to a new folder:
cp -rp /var/www/html/old_domain.com/. /var/www/html/new_domain.com/As usual,
-rpmeans 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
.htaccesswhich 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.
- 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.
- Remove (or disable) WordPress files from the old location so that it does not access database of WordPress running at a new location.
- Check if any additional files contain link(s) to the old domain. For example,
sitemap.xmlmay need to be rebuilt as it contains full links that start with
http://and therefore contain domain name. Can use
grepcommand for this,
-rfor Recursive (do not forget to navigate for the new folder first):
cd /var/www/html/new_domain.com/ grep -r 'old_domain.com' *
- Check both front and back end but that should be it – happy blogging!
966 total views, 2 views today