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.
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 onto 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 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 a MySQL database.
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.
define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com');
- 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'); $table_prefix = 'yourtableprefix';
- 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.
- yourtableprefix with the correct table prefix.
Note: If your site is hosted on Managed WordPress, the row with the hostname should have the following structure:
define('DB_HOST', 'yourhostname:portnumber');
You should replace yourhostname with the correct MySQL host name and portnumber with the correct port number.
- Save the updated wp-config.php file.
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:
define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com');
You successfully changed your domain name and moved your site to a new server or host.