Get a free website with any plan

See how
WORDPRESS

Changing your WordPress site's domain

Last updated

IN SHORT

To change a WordPress site's domain, update the siteurl and home options in Settings > General, then run a search-replace (Better Search Replace plugin or wp search-replace via wp-cli) across the database to catch old URLs in content and serialized plugin data.

Moving your WordPress site to a different domain — rebrand, consolidating from multiple domains, switching from .dev to .com after launch — requires updating the site's URL settings and search-replacing old URLs in the database.

The pieces involved

Three places store the site's URL:

  1. WordPress options tablesiteurl and home settings (visible in wp-admin → Settings → General).
  2. Content — your posts, pages, custom fields. Old URLs in image references, links, etc.
  3. Database tables — some plugins store URLs in serialized data (e.g., widget settings, theme options).

All three need updating.

Easiest: Search-Replace plugin

For most sites:

  1. Install Better Search Replace plugin (free).
  2. Go to Tools → Better Search Replace.
  3. Configure:
    • Search for: old URL (e.g., https://olddomain.com).
    • Replace with: new URL (e.g., https://newdomain.com).
    • Select tables: all of them (or at least wp_options, wp_posts, wp_postmeta, wp_options).
    • Run as dry run first — see what would change without committing.
  4. Run the dry run, review, then run for real.

The plugin handles serialized data correctly — replacing strings inside serialized arrays without breaking them. This is the key thing distinguishing it from raw SQL search-replace.

Update siteurl and home

After the search-replace runs, also update these explicitly:

wp-admin → Settings → General:

  • WordPress Address (URL): https://newdomain.com
  • Site Address (URL): https://newdomain.com

These should match what the search-replace updated. If you ran a comprehensive search-replace, they're likely already correct.

Manual: wp-cli

For developer-friendly sites with shell access:

cd /home/your-user/public_html

# Update siteurl and home
wp option update home 'https://newdomain.com'
wp option update siteurl 'https://newdomain.com'

# Search-replace across all content (handles serialized data)
wp search-replace 'olddomain.com' 'newdomain.com'

# Flush rewrite rules
wp rewrite flush

The wp search-replace command is wp-cli's built-in equivalent of the Better Search Replace plugin. It's faster and safer than manual SQL.

When you can't access wp-admin

If your site won't load after the change (because the URL settings don't match where you actually visit it from), update via:

Option 1: wp-config.php override

Add to wp-config.php:

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

These hard-code the URL settings, overriding what's in the database. WordPress loads correctly at the new URL.

Option 2: Database update via phpMyAdmin

  1. Open phpMyAdmin from your hosting.
  2. Navigate to your WordPress databasewp_options table.
  3. Find rows where option_name is home and siteurl. Edit option_value to your new domain.
  4. Save.

WordPress's URL settings now match the actual URL.

DNS cutover

Don't forget DNS:

  1. Point newdomain.com at your hosting's IP (or use our nameservers). See Pointing your domain to your hosting.
  2. Wait for DNS propagation.
  3. Test the site loads at the new domain.

If you're keeping the old domain working too, set up a 301 redirect from olddomain.comnewdomain.com. See Redirecting URLs.

Common issues after domain change

Mixed content warnings

Browser shows "not secure" or "mixed content" because some asset URLs are still pointing at the old domain. Run a more thorough search-replace; check wp-content/themes/your-theme/ for hardcoded URLs.

Broken images

Image URLs in posts are still pointing at the old domain. Search-replace should fix; if not, check the database wp_posts table directly.

Cached pages still show old URL

Flush all caches:

  • wp-admin → LiteSpeed Cache → Toolbox → Empty Entire Cache.
  • Cloudflare → Caching → Purge Everything.
  • Browser hard-refresh.

Theme/plugin custom settings broken

Some themes and plugins store URLs in their own settings structures (often serialized). If they use absolute URLs and don't get caught by search-replace:

  • Look in wp_options for plugin-specific rows referencing the old URL.
  • Update them via phpMyAdmin or the plugin's own settings page.

Power-user note

For sites with serialized data in custom database tables (not just wp_options or wp_postmeta), the safer search-replace tool is WP Migrate Lite or its paid version WP Migrate. They handle a wider range of serialized data types than Better Search Replace.

For migrations between development/staging/production environments, set up a wp-cli workflow:

wp search-replace 'staging.yourdomain.com' 'yourdomain.com' --all-tables --dry-run

The --all-tables flag covers custom plugin tables. --dry-run previews without committing.

Common questions

Why does my site still show the old domain after I changed the URL settings?

The URL settings only cover siteurl and home. Old URLs are usually still saved in your posts, pages, and serialized plugin data, so you need a search-replace across the database, not a settings change alone.

Can I use regular SQL search-replace instead of a plugin?

Not safely. Plugins like Better Search Replace and the wp-cli wp search-replace command handle serialized data correctly, replacing strings inside serialized arrays without breaking them. Raw SQL search-replace can corrupt that data.

What do I do if my site won't load at all after changing the domain?

Add WP_HOME and WP_SITEURL overrides to wp-config.php, or edit the home and siteurl rows directly in the wp_options table via phpMyAdmin. Either one makes WordPress load correctly even if wp-admin is unreachable.

Why do I still see mixed content warnings after the domain change?

Some asset URLs are still pointing at the old domain, often hardcoded in your theme files. Run a more thorough search-replace and check wp-content/themes/your-theme/ for hardcoded URLs.

Do I need to do anything with DNS when I change my WordPress domain?

Yes. Point the new domain at your hosting's IP or nameservers, wait for DNS propagation, and test that the site loads. If you want the old domain to keep working, set up a 301 redirect from the old domain to the new one.

CAN'T FIND IT?

Real humans answer fast.

Hosting with us? Open a ticket and a real person replies - no scripts, no upsells. Still choosing a host? The same team is included with every plan, from day one.