New 24/7 monitoring and daily cloud backups now included in every Shield Pro plan.

Migration

Learn how to change a WordPress URL and domain.

Moving from staging to live or http to https means updating WordPress URLs in more than one place. Hardcoded links in content and serialized options break if you edit the database carelessly.

Time: 30-60 minutes Level: Intermediate
Neil McNaught, founder of BugShield and WordPress author
Written by
Written by
Updated
Updated

What this problem looks like

WordPress stores the site address in wp_options and embeds URLs inside post content, meta, and widget data. A domain change needs both settings updated and a careful database replace.

Never use plain SQL REPLACE on the whole database when plugins store serialized PHP arrays. Length changes corrupt serialized data.

Step 1: Change URL in wp-admin

  1. Settings → General.
  2. Update WordPress Address and Site Address to the new URL.
  3. Save. You may need to log in again at the new URL.

Step 2: Lock URLs in wp-config.php

Open wp-config.php in your site root, next to wp-admin and wp-content. Search for WP_HOME and WP_SITEURL first. If those lines already exist, update them instead of adding duplicates. If neither exists, paste the constants above the line that says stop editing:

php
define( 'WP_HOME', 'https://newdomain.com' );
define( 'WP_SITEURL', 'https://newdomain.com' );

Step 3: Search-replace with WP-CLI on SSH

Only run these commands if you have SSH access to the server.

bash
wp search-replace 'https://olddomain.com' 'https://newdomain.com' --all-tables --precise
wp search-replace 'https://olddomain.com' 'https://newdomain.com' --network --url=olddomain.com

Step 4: Update .htaccess and redirects

Find .htaccess in your site root, next to wp-admin and wp-content. Add 301 redirects from the old domain on the old host so SEO and bookmarks survive.

Update Google Search Console and analytics properties after cutover.

Step 5: Common problems after URL change

  • Login redirect loop: cookie domain or http/https mismatch.
  • Mixed content: hardcoded http assets in posts.
  • Broken media: uploads URL still pointing at old CDN.

When to stop DIY and hire help

Domain moves on WooCommerce and multisite need serialized-safe replaces and checkout testing. BugShield handles WordPress URL changes at a confirmed fixed price.

Questions answered

Changing a WordPress URL and domain FAQs

Answers about backups, DNS, stored URLs, redirects, HTTPS, email, and checking a WordPress domain change.

Can I change URL without database access?

wp-config.php constants change the main addresses but post content links stay old until you search-replace.

Should siteurl include a subdirectory?

Yes if WordPress lives in a subfolder. Both URLs must match the real path visitors use.

Will changing URL break Elementor or builders?

Builders store JSON with URLs. Use builder tools or WP-CLI replace that handles serialized data.

How do I switch http to https only?

Update URLs to https, force server redirect, then replace remaining http links in the database.

What should I back up before changing a WordPress domain?

Save the full database, uploads, themes, plugins, configuration, and server rules. Keep the copy until redirects, email, forms, login, and search indexing are verified.

Should I update DNS before changing WordPress URLs?

Prepare the new hosting and certificate first, lower DNS TTL in advance when possible, then coordinate DNS and WordPress changes to minimise disruption.

How do I replace the old domain inside WordPress content?

Use WP-CLI or a WordPress-aware search-replace tool that preserves serialized data. Run a dry test and replace only the exact old hostname.

Do I need redirects after changing a WordPress domain?

Yes. Add one-to-one permanent redirects from old URLs to their new equivalents and keep the old domain under your control.

Can changing a WordPress domain affect email delivery?

Yes. Update form recipients, sender addresses, SMTP settings, SPF, DKIM, DMARC, MX records, and any external service that authorises the old domain.

How do I verify a WordPress domain change?

Test old and new URLs, HTTPS, wp-admin, media, forms, email, redirects, canonical tags, sitemap, analytics, Search Console, and checkout or customer accounts.

Would you rather a developer fixed it?

Request a fix at a confirmed price and speak directly with the BugShield developer working on your site.

Request a Fix