WordPress is a flexible CMS and moving it to a new location is straightforward. No need to re-install. Still, there are a few things to keep in mind.
In a WordPress Multisite, the steps outlined here might not be the best way!
Backup your Files and Database
While this isn’t necessary per se, it doesn’t hurt, does it? Better safe than sorry.
Download all the files via FTP and export your database to your computer.
Edit your URLs
Log into your WordPress backend, then go to Settings > General. There, change the URLs to reflect the future site URL.
You will receive a 404 error. That is expected behavior.
Move your Files (and Database)
Once you have edited the URLs, move the files to the new location.
Edit your wp-config.php
If the name of your database, the user, or the password has changed, edit wp-config.php to reflect those changes. The file is in the root folder or your WordPress installation.
Look for the following values:
define( 'DB_NAME', 'example_database' ); define( 'DB_USER', 'example_username' ); define( 'DB_PASSWORD', 'example_password' ); define( 'DB_HOST', 'localhost' );
You should now be able to log into WordPress again. (But don’t forget to use the new URL and add /wp-admin/ at the end.)
If oftentimes (and doesn’t hurt) makes sense to go to Settings > Permalinks and click Save Changes there. That will flush old, internal links.
Replace Remaining Old Links
Now some images will probably not load, because they still point to the old location.
You could go in the database and manually look for and replace those old links, or you can use a simple plugin that was made just for this:
If Things Go Wrong
You still have the backup of your database and files, so first of all, don’t worry.
Can’t Access the WordPress Backend
This usually happens when you didn’t edit your URLs before moving the files. Not to worry.
In your wp-config.php, you can force WordPress to use a different URL. Add the following files to the file:
define( 'WP_HOME', 'https://example.com' ); define( 'WP_SITEURL', 'https://example.com' );
This article is neither painting a complete picture of the topic nor is it trying to. It serves as a mnemonic and notebook for Marvin.
If you found a mistake, want to add something or found the article helpful, please get in touch.