How do I move WordPress to a new domain name?

Procédure

To move a WordPress site to a new domain name, you copy its files and database to the hosting of the new domain, adjust the wp-config.php file, then replace the old address with the new one in the WordPress settings. If your site is hosted on LWS Panel, WP Manager does all of this for you, without FTP or phpMyAdmin.

The manual method below is for other cases: a site hosted somewhere other than LWS, a new domain on another type of hosting, or a site that WP Manager does not support. The screen examples are those of LWS Panel.

Why changing a WordPress site’s domain name requires precautions

WordPress stores the site address in its database. If you copy the site without changing it, it will continue sending visitors to the old address. The links you wrote in your posts and pages also keep the old domain: once the old site is deleted, they lead to 404 errors.

Back up the site before making any changes

Moving the site changes the database, and an SQL query that has been executed cannot be undone. Before starting, keep a full copy of the site on your computer, in two parts:

These two copies are also used for the next steps: they are the ones you upload to the new hosting. Keep them unchanged until the new site works.

Copy the site to the new domain’s hosting

  1. Upload the files by FTP

    Your FTP credentials are in the LWS Panel of the new hosting, section Files > FTP Account(s), block FTP user list. The password is not shown there: if it is lost, click Change on the account line. Connecting with FileZilla is explained in How do I publish a site by FTP with FileZilla, Cyberduck or WinSCP?.

    Upload all the backed-up files into the new domain’s folder, inside /htdocs:

    • for a subdomain, its folder bears its full name, for example /htdocs/blog.new-domain.fr/;
    • for a domain added as an “Independent domain”, it is the folder indicated in the Directory column of the Domain management > Multi Domains section;
    • for the main domain, it is the folder bearing its name if it exists (/htdocs/new-domain.fr/), otherwise /htdocs directly.

    The LWS Panel file manager (section Files) lets you view these folders before uploading.

  2. Create a database on the new hosting

    In the LWS Panel, section Databases & PHP, open MySql & Phpmyadmin and click Click here to create a MySql database. The database name, user, and password are generated by LWS: the password is sent to you by email and is no longer displayed afterward in the panel. See How do I create a Mysql database?.

  3. Import the database into phpMyAdmin

    On the line for the new database, click the ⋮ menu then PhpMyAdmin. phpMyAdmin opens in a new tab: the connection is not automatic, enter the database user (column User) and its password. Then import the exported file from the old database, as explained in How to import a database on LWS shared hosting with phpMyAdmin. For a large file, follow How do I import a large database on LWS Panel?.

  4. Point wp-config.php to the new database

    The wp-config.php file, in the root of the copied site, contains the database connection settings. First make a copy of it (for example wp-config.php.before): if the site no longer displays, restore this copy. Then modify the following four lines with the values from the MySql & Phpmyadmin table:

    📄 wp-config.php
    define( 'DB_NAME', 'database_name' );
    define( 'DB_USER', 'database_user' );
    define( 'DB_PASSWORD', 'database_password' );
    define( 'DB_HOST', 'mysql_server_ip_address' );
    wp-config.php lineWhere to read the value in the LWS Panel
    DB_NAMEDatabase column
    DB_USERUser column
    DB_PASSWORDThe password received by email when the database was created (lost: ⋮ menu > Change password)
    DB_HOSTServer IP column: an IP address, not “localhost”

    Also note the value of the line starting with $table_prefix (default 'wp_'): this is the beginning of your site’s table names, useful in the next step.

Replace the old address with the new one

The changes below are those documented by WordPress in its official guide, section “Changing The Site URL” (Moving WordPress, on developer.wordpress.org). Make them in the new site’s database, after importing, and keep your backup close at hand.

  1. Change the site address in the options table

    In phpMyAdmin, click the database name in the left column, then the wp_options table (replace wp_ with your prefix if it is different). On the row where the option_name column is siteurl, edit the option_value column: enter the new full address, with https:// and no trailing slash, for example https://new-domain.fr. Confirm with Go. Do the same for the home row.

  2. Correct the links written in your posts and pages

    Your content may contain links and images with the old address. The query below is a template to adapt: replace the two addresses with your own, written exactly as on the site (with https:// or http://, with or without www), and replace wp_posts with the table name using your prefix. In phpMyAdmin, open the database’s SQL tab, paste the adapted query, then click Go.

    Code
    UPDATE wp_posts SET post_content = REPLACE(post_content, 'https://www.old-domain.fr', 'https://www.new-domain.fr');

Check that everything works

Open the new address in your browser and browse a few pages: the text, images, and menus display, and the address at the top of the browser remains the new one. Then log in to the administration area at https://new-domain.fr/wp-admin: in Settings > General, the two address fields (WordPress address and site address) must show the new address.

To send visitors from the old domain to the new one, set up a redirect: Redirect a domain name to another web address.

Frequently asked questions

My new site shows “Error establishing a database connection”

Compare the four lines in wp-config.php with the database line in MySql & Phpmyadmin: database name, user, and server IP address. If you are unsure about the password, change it using the ⋮ menu > Change password, then enter it again in wp-config.php.

The new domain redirects me to the old site

The siteurl and home lines in the options table still contain the old address. Check them in phpMyAdmin, in the new site’s database, and also verify that wp-config.php points to this new database and not the old one.

Is there a method without phpMyAdmin?

Yes. On LWS Panel hosting, WP Manager moves the site without FTP or queries (see the boxed note at the top of this help article). From another host, a migration plugin performs the transfer: see How to migrate a WordPress site with the All-in-One WP Migration plugin.

Related articles

help.lws.net/a/1009
Was this article helpful?

Yes

No

Read 28 392 times

Thank you! Feel free to ask questions about our documentation if you would like more information, and help us improve it.

Similar articles

A question about this article?

Ask the LWS team and the community. Answers are published after moderation.

Ask the LWS team and its community a question

GDPR: Controller: LWS-Ligne Web Services. Purpose: moderation and public publication of your question, possible notification of an answer. Legal basis: consent (Art. 6(1)(a) GDPR). Email retention: 90 days after notification, 12 months maximum without an answer. To exercise your rights, see the GDPR section of our Terms and Conditions.