WordPress migration to a new domain: old-domain.com redirected with a 301 to new-domain.com

WordPress Migration to New Domain: Steps and 301s

To do a WordPress migration to a new domain, back up the site, move it to the new domain, update every old URL in the database, and add 301 redirects from the old domain to the new one. Skipping the URL update or the redirects is what causes broken images, dead links and lost search traffic.

The steps below work for a domain change on the same host or a move to a new host at the same time. If the domain stays the same and only the host changes, use our guide to moving a WordPress site to a new host instead.

Before you change the domain: checklist

  • Keep the old domain active and pointing to the old site until the new one is verified.
  • Make a full backup of files and database, and download a copy to your computer.
  • List every place the old domain may be hard-coded: wp-config.php, theme settings, page builder data, email settings, payment gateway and webhook URLs.
  • Check that the new domain has SSL available, so you can start on HTTPS.
  • Plan a quiet time for the switch, especially for a store with live orders.

Step 1: Back up files and database

Do not skip this. A URL change edits many database rows, and an edit cannot be undone without a copy. Follow our backup and restore guide and confirm you can actually restore the backup before moving on.

Step 2: Move the site to the new domain

Point the new domain at your hosting, add it as a domain or addon domain in your control panel, and copy the WordPress files and database to the new location. If you are moving on the same hosting account, you can often just change the site root. If the move also changes servers, our guide on migrating a WordPress site without downtime covers the safe order of work.

Update the database name, user and password in wp-config.php if they changed, then load the site on the new domain.

Step 3: Update the old URLs in the database

WordPress stores the old domain in settings, posts, widgets, menus and page builder data. Changing only Settings, General is not enough. You need a search and replace across the database that handles serialized data safely. WordPress.org documents this in its migrating WordPress guide, which warns that a plain find and replace can break serialized data when the URL length changes.

With WP-CLI over SSH, run a dry run first:

wp search-replace 'https://old-domain.com' 'https://new-domain.com' --dry-run

Read the report, and if the counts look right, run the same command without --dry-run. The WP-CLI search-replace documentation confirms it handles PHP serialized data. If you have no SSH access, a search and replace plugin that supports serialized data does the same job. Repeat for the http:// and www versions of the old domain if they appear.

If you are locked out of wp-admin because the URL is wrong, you can temporarily set WP_HOME and WP_SITEURL in wp-config.php to the new address, log in, then fix the database values properly.

Step 4: Add 301 redirects from the old domain

A 301 redirect tells browsers and search engines the move is permanent and sends each old URL to the same page on the new domain. On an Apache server, add this to the .htaccess file of the old domain, above the WordPress block:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]

This keeps the path, so /services/ on the old domain lands on /services/ on the new one. On Nginx or LiteSpeed setups the rule is written differently, so check with your host. If the redirect causes a loop, see our guide to WordPress too many redirects.

Step 5: Test the new domain

  1. Open the home page, a blog post, a category page and the contact page in a private window.
  2. Check that images load and that the padlock shows on every page.
  3. Click through the main menu and a few internal links to confirm none point to the old domain.
  4. Submit a form and send a test email to confirm they still work.
  5. On a store, place a test order and confirm payment and webhook URLs use the new domain.
  6. Open the old domain and confirm it redirects to the matching page on the new one.

Common problems after a domain move

  • Images not showing: the database still holds old image URLs, or wp-content/uploads was not copied fully. Re-run the search and replace and re-upload the folder.
  • Links not working or redirecting to the old site: an old URL is left in the database, a page builder setting, or a redirect plugin. Search the database again and clear all caches.
  • 404 errors on inner pages: re-save permalinks under Settings, Permalinks and check .htaccess was copied. Our WordPress 404 error guide lists more causes.
  • Mixed content warnings: some URLs are still HTTP after moving to HTTPS. Replace them in the database.

Need help with a WordPress domain migration?

I have 10+ years of experience with WordPress migrations, and I am Top Rated on Upwork with a 100% Job Success score. If you would rather hand the move to someone else, see my WordPress migration service or get in touch. I reply within 24 hours.

Frequently Asked Questions

Will changing my domain hurt my SEO?

Rankings can dip for a while after any domain change, but proper 301 redirects from every old URL to its new match, plus a clean site on the new domain, reduce the risk. Missing redirects and broken pages are the usual cause of lost traffic.

Can I just change the URL in Settings, General?

That only changes two settings. Old URLs stay in posts, menus, widgets and page builder data, so images and links can break. Run a search and replace across the database as well.

How long should I keep the old domain?

Keep it renewed and redirecting for as long as you can, ideally at least a year, so old links, bookmarks and search results keep working.

Leave a Reply

Your email address will not be published. Required fields are marked *

638028265_26170227569275320_6333876549114972331_n

Meet Muhammad Aziz

Muhammad Aziz is a results-driven web developer specializing in WordPress, WooCommerce, and custom web solutions that transform ideas into scalable, high-performance digital products.

Related Posts

Explore more

Keep reading

Latest articles

Practical WordPress, WooCommerce and speed guides from real client projects.

View all articles

Ready to start your project? Contact us

Tell us about your goals, and we’ll respond within 24 hours
with a clear plan and detailed quote.