WP AI Agent
Features Pricing Blog Contact Download Plugin Manage Subscription Get Free Key →

How to Move WordPress to a New Domain: Complete Step-by-Step Guide

· · 9 min read

Moving WordPress to a new domain is one of the most important technical tasks a site owner can undertake, and doing it correctly ensures you preserve your content, SEO rankings, and user experience. Whether you are rebranding, upgrading to a better domain name, or consolidating multiple sites, this comprehensive guide walks you through every stage of the migration process with confidence.

Why Moving WordPress to a New Domain Requires Careful Planning

A WordPress site stores its domain name in two critical places: the wp_options table in the database (as siteurl and home) and throughout post content as absolute URLs. If you simply copy files without updating these references, your site will break, images will not load, and internal links will redirect visitors back to the old domain. Planning ahead prevents data loss, downtime, and SEO penalties.

What You Risk Without Proper Migration

  • Broken internal links and missing media files
  • Loss of Google search rankings due to missing 301 redirects
  • Logged-out users and corrupted session data
  • SSL certificate errors on the new domain
  • Plugin licence invalidation tied to the old URL

Choosing the Right Migration Method

There are three primary methods for moving WordPress to a new domain: using a migration plugin, using WP-CLI commands, or performing a fully manual database-and-files approach. This guide covers all three so you can choose based on your comfort level and server access.

Step 1 — Back Up Your Entire WordPress Site

Before touching a single file, create a complete backup. This is non-negotiable. A backup gives you a safety net if anything goes wrong during the migration.

  1. Log in to your WordPress dashboard and install a backup plugin such as UpdraftPlus or Duplicator.
  2. Run a full backup that includes both the database and all files (themes, plugins, uploads).
  3. Download the backup archive to your local computer — do not rely solely on server storage.
  4. Export your database separately via phpMyAdmin: select your database, click Export, choose SQL format, and save the .sql file.
  5. Compress your entire WordPress root folder via your hosting file manager or FTP into a .zip archive.

Verifying Your Backup

Open the SQL file in a text editor and confirm it contains CREATE TABLE statements and your domain URL in the wp_options rows. Check the zip archive to confirm the wp-content folder is present and not empty.

Step 2 — Copy Files and Database to the New Domain

With a verified backup in hand, the next phase is transferring your WordPress installation to the new domain's hosting environment.

Transferring Files via FTP or File Manager

  1. Connect to your new hosting account using an FTP client such as FileZilla or use the hosting control panel's file manager.
  2. Upload all WordPress files to the public_html (or equivalent root) directory of the new domain.
  3. Ensure hidden files — especially .htaccess — are transferred. In FileZilla, enable View > Show hidden files.

Importing the Database

  1. Create a new MySQL database and database user in your new hosting control panel (cPanel, Plesk, etc.).
  2. Grant the new user ALL PRIVILEGES on the new database.
  3. Open phpMyAdmin on the new host, select the new database, click the Import tab, and upload your .sql file.
  4. Update the wp-config.php file in your transferred files to point to the new database credentials:
// wp-config.php — update these four constants
define( 'DB_NAME',     'your_new_database_name' );
define( 'DB_USER',     'your_new_db_user' );
define( 'DB_PASSWORD', 'your_new_db_password' );
define( 'DB_HOST',     'localhost' );

Step 3 — Update the Domain URL in the Database

This is the most critical step. Every instance of your old domain in the database must be replaced with the new domain. WordPress serialises data, so a simple SQL find-and-replace will corrupt serialised strings — always use a tool designed for this purpose.

Method A: Using WP-CLI (Recommended for Developers)

WP-CLI's search-replace command handles serialised data automatically and is the fastest reliable method available:

# SSH into your server and run from the WordPress root directory
wp search-replace 'https://olddomain.com' 'https://newdomain.com' \
  --skip-columns=guid \
  --all-tables \
  --report-changed-only

# Flush the cache after replacing
wp cache flush

The --skip-columns=guid flag preserves post GUIDs, which is considered best practice for RSS feed compatibility. The --all-tables flag ensures plugin tables are also updated.

Method B: Using the Better Search Replace Plugin

  1. Install and activate the Better Search Replace plugin on the new domain (once the database is connected).
  2. Navigate to Tools > Better Search Replace.
  3. Enter your old domain in the Search for field (e.g., https://olddomain.com).
  4. Enter your new domain in the Replace with field (e.g., https://newdomain.com).
  5. Select all tables and check Run as dry run first to preview changes.
  6. Uncheck dry run and click Run Search & Replace to apply the changes.
  7. Delete or deactivate the plugin after completing the replacement.

Method C: Manual SQL Update (Minimal Change)

If you only need to fix the core site URL settings and will handle serialised content separately, run these two SQL queries in phpMyAdmin:

UPDATE wp_options SET option_value = 'https://newdomain.com'
  WHERE option_name = 'siteurl';

UPDATE wp_options SET option_value = 'https://newdomain.com'
  WHERE option_name = 'home';

Note: This method alone is not sufficient for a full migration — it only corrects the site URL settings and does not update hardcoded URLs in post content or plugin settings.

Step 4 — Configure Permalinks, SSL, and Test the New Site

After updating the database, several configuration steps ensure the new domain functions correctly before you go live.

Flushing Permalinks

  1. Log in to the WordPress dashboard on the new domain.
  2. Go to Settings > Permalinks.
  3. Without changing anything, click Save Changes. This regenerates the .htaccess rewrite rules for the new domain.

Installing and Verifying SSL

Your new domain needs a valid SSL certificate. Most modern hosts offer free Let's Encrypt certificates via cPanel. Once installed, verify HTTPS loads correctly and that there are no mixed-content warnings in your browser's developer console. If the Really Simple SSL plugin is installed, reactivate it on the new domain to handle any remaining HTTP references.

Testing Checklist Before Going Live

  • Homepage loads correctly with the new domain in the address bar
  • Images and media files display without broken icons
  • Internal links navigate to the new domain, not the old one
  • Contact forms submit successfully
  • User login and registration work as expected
  • WooCommerce or e-commerce checkout functions (if applicable)
  • Admin dashboard is fully accessible at https://newdomain.com/wp-admin/

Step 5 — Set Up 301 Redirects and Update External References

Even after a successful migration, visitors and search engines may still try to access the old domain. Setting up 301 permanent redirects is essential for preserving your SEO authority and ensuring a seamless user experience.

Adding 301 Redirects via .htaccess on the Old Domain

If the old domain's hosting is still active, add the following rule to the .htaccess file in the old domain's root directory:

# Redirect all traffic from old domain to new domain
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]

This preserves the URL path (e.g., olddomain.com/blog/post-title redirects to newdomain.com/blog/post-title), which is critical for maintaining individual page rankings in Google.

Updating External References and Google Tools

  1. Google Search Console: Add the new domain as a property and submit your updated XML sitemap (found at https://newdomain.com/sitemap.xml). Use the Change of Address tool if both domains are verified.
  2. Google Analytics: Update the data stream URL in your GA4 property settings.
  3. Backlinks: Contact high-authority sites that link to your old domain and request a URL update.
  4. Social media profiles: Update your website URL on all social platforms.
  5. Email signatures and marketing materials: Update any printed or digital materials that reference the old domain.
  6. Plugin licences: Reactivate licences for premium plugins (e.g., Yoast SEO Premium, Gravity Forms) using the new domain.

Monitoring Post-Migration Health

Use tools like Screaming Frog or Ahrefs Site Audit to crawl the new domain and identify any remaining broken links or missed URL replacements. Monitor Google Search Console's Coverage report for crawl errors over the first 30 days after migration.

Frequently Asked Questions

Will moving WordPress to a new domain hurt my SEO rankings?

A properly executed domain migration with 301 redirects in place typically causes only a temporary, minor dip in rankings. Google follows 301 redirects and transfers the majority of link equity to the new domain. Most sites recover their rankings within a few weeks, especially if the new domain is closely related to the old one and the site content remains unchanged.

How long should I keep the old domain active after migrating?

It is strongly recommended to keep the old domain active and redirecting for a minimum of 12 months. This ensures that any cached links in search engines, backlinks from external sites, and bookmarked URLs continue to work. After 12 months you can evaluate whether traffic to the old domain has dropped to near zero before letting it expire.

Do I need to update wp-config.php with the new domain URL?

You do not need to hardcode the domain in wp-config.php unless you are troubleshooting a login loop or want to override database settings. The siteurl and home values in the wp_options table control the domain. However, you can add define('WP_HOME','https://newdomain.com'); and define('WP_SITEURL','https://newdomain.com'); temporarily to regain dashboard access if the database update has not yet been applied.

Can I move WordPress to a new domain without a plugin?

Yes. The fully manual method — exporting the database, transferring files via FTP, updating database credentials in wp-config.php, and running a WP-CLI search-replace command — requires no migration plugin. This approach is often faster for experienced developers and avoids potential compatibility issues that plugins can introduce. The WP-CLI method described in this guide is the most reliable manual approach available.

Successfully moving WordPress to a new domain takes careful preparation, the right tools, and thorough post-migration checks — but it is entirely manageable when you follow each step methodically. If you would prefer to delegate complex WordPress tasks like domain migration, database search-replace operations, redirect configuration, and Search Console updates, WP AI Agent is a powerful tool that lets you accomplish all of these through simple natural-language AI chat, making advanced WordPress management accessible to everyone regardless of technical skill level.

Ready to manage WordPress with AI?

Get 100,000 tokens free every month. No credit card required.

Get Your Free License Key →

More from the blog