How to migrate wordpress site to new domain

Migrating a WordPress site to a new domain can be a bit of a process, but it's definitely doable. Here's a step-by-step guide to help you through the process:

Before you start:

  1. Backup your site: Make sure to backup your WordPress site, including the database and files, before making any changes. This will ensure that you can restore your site if anything goes wrong during the migration process.
  2. Update your DNS: Update your DNS settings to point to the new domain. This may take some time to propagate, so be patient.

Step 1: Update your WordPress configuration

  1. Update the wp-config.php file: Open the wp-config.php file in a text editor and update the DB_HOST, DB_USER, and DB_PASSWORD variables to reflect the new database host, username, and password.

  2. Update the wp_options table: Run the following SQL query to update the wp_options table with the new domain:

    UPDATE wp_options SET option_value = REPLACE(option_value, 'old-domain.com', 'new-domain.com') WHERE option_name = 'site_url' OR option_name = 'home_url';

    Step 2: Update your theme and plugins

  3. Update your theme: Update your theme to ensure that it's compatible with the new domain. You may need to update the theme's style.css file to reflect the new domain.

  4. Update your plugins: Update your plugins to ensure that they're compatible with the new domain. You may need to update the plugin's settings or configuration files to reflect the new domain.

Step 3: Update your database

  1. Export your database: Export your WordPress database using phpMyAdmin or a similar tool.

  2. Update the database: Update the database by running the following SQL queries:

    UPDATE wp_posts SET post_content = REPLACE(post_content, 'old-domain.com', 'new-domain.com');
    UPDATE wp_posts SET post_title = REPLACE(post_title, 'old-domain.com', 'new-domain.com');
    UPDATE wp_options SET option_value = REPLACE(option_value, 'old-domain.com', 'new-domain.com');

    Step 4: Update your files

  3. Update your files: Update your WordPress files to reflect the new domain. You'll need to update the following files:

    • wp-config.php
    • wp-content/themes/your-theme/style.css (if you're using a custom theme)
    • wp-content/plugins/your-plugin/plugin-file.php (if you're using a custom plugin)
  4. Update your images: Update your images by running the following command:

    find. -type f -name "*.jpg" -o -name "*.png" -o -name "*.gif" -exec sed -i 's/old-domain.com/new-domain.com/g' {} \;

    Step 5: Update your DNS

  5. Update your DNS: Update your DNS settings to point to the new domain. This may take some time to propagate, so be patient.

Step 6: Test your site

  1. Test your site: Test your site to ensure that everything is working as expected. Check that all links, images, and other assets are loading correctly.

Additional tips: