Change my WordPress domain name while moving my site to a new location
There are different ways to move your WordPress site between servers. You should only use this method if you want to change the domain name your WordPress site is hosted on while you are moving the site to a new server or host.
Note: If you want to simply change your WordPress domain name, see Changing Your WordPress Domain Name.
To get started, you need to set up WordPress on your hosting account. Once WordPress is set up, you need to export your existing site and database, and then import it along with the database on to the new server. Finally, to complete the process, you need to update your wp-config.php file and repair any broken links on your site.
Export and download your site away from a server
To export and download your WordPress site from your current host, you need to back up your existing database and have access to the WordPress files on your existing server.
- Identify the database that your WordPress site uses, and then create a backup of your database as an SQL file. For more information, see the official WordPress documentation.
- Connect to your existing hosting account using File Transfer Protocol (FTP). For more information see What is File Transfer Protocol (FTP)?
- Download the entire contents of the wordpress folder to your computer.
Import and upload a WordPress site to a new location
To import and upload your WordPress site to our servers, you need to access the new hosting server and database.
- Connect to your new hosting account using FTP.
- Upload and replace the contents of the wordpress folder you saved.
- Create a new MySQL database (cPanel / Plesk).
- Note the database's Database Name, Host Name, and the password you used.
- Restore the SQL file you saved into your new database. For more information, see Import SQL files into MySQL databases.
Update your wp-config.php file
To make your site work again, you need to update the wp-config.php file with your new domain name.
- In the FTP app, open your wp-config.php file.
- Add the following two lines to the file, where example.com is the correct location of your site. For more information, see the official WordPress documentation.
- Locate the section that looks like this example:
/** The name of the database for WordPress */ define('DB_NAME', 'putyourdbnamehere'); /** MySQL database username */ define('DB_USER', 'usernamehere'); /** MySQL database password */ define('DB_PASSWORD', 'yourpasswordhere'); /** MySQL hostname */ define('DB_HOST', 'localhost');
- Enter the database information from your database as follows:
- putyourdbnamehere: Replace this with your MySQL Database Name.
- usernamehere: Replace this with your MySQL Database Username.
- yourpasswordhere: Replace this with your MySQL Password.
- localhost: Replace this with your MySQL Host Name.
- Save your modifications.
Fix broken links after moving your WordPress site
Finally, you need to clean your site of outdated link paths.
- Sign in to WordPress.
- From the Plugins menu, select Add New.
- Type Better Search Replace.
- Find the Better Search Replace plugin and select Install Now.
- When the plugin has installed, select Activate.
- From the Tools menu, select Better Search Replace.
- Enter your old site URL in the Search for field. For example, http://olddomainexample.com (no trailing slash).
- Enter your new site URL in the Replace with field. For example, http://newdomainexample.com (no trailing slash).
- Select all database tables from the Select tables field.
- Uncheck the Run as dry run checkbox.
- Select Run Search/Replace to replace the URLs in the database.
- In the FTP app, open your wp-config.php file, and remove the following two lines:
You successfully changed your domain name and moved your site to a new server or host.