Skip to main content

Your privacy

We store what the site needs to work, like a notice you closed or your domain shortlist. With your OK we also use Google Analytics to see which pages help people, and the Meta Pixel to measure which of our adverts work. Privacy policy

Serverlys
WordPress

Change your WordPress site URL safely

Move WordPress to a new domain or address without breaking links, serialised settings or your own login.

All WordPress tutorials6 stepsAbout 20 minutes

Before you start

  • A fresh backup of the database
  • The new domain already resolving to the server, with a valid certificate
  • SSH with WP-CLI, or FTP access to wp-config.php
  1. Step 1: Know the two settings

    WordPress stores its address twice, in the options table: home (the Site Address, what visitors type) and siteurl (the WordPress Address, where its files live). For most sites they are identical. Write them without a trailing slash.

  2. Step 2: Change them in the dashboard if you can

    Settings → General. Saving logs you out, because your login cookie belongs to the old address; log in again at the new one. If the fields are greyed out, they are fixed in wp-config.php and must be changed there.

  3. Step 3: Or change them from outside WordPress

    If you are locked out, either define the addresses in wp-config.php or update the options with WP-CLI. Constants in wp-config.php override the database, so remove them later if you want the dashboard fields back.

    define( 'WP_HOME', 'https://newdomain.com' );
    define( 'WP_SITEURL', 'https://newdomain.com' );
    
    # or
    wp option update home 'https://newdomain.com'
    wp option update siteurl 'https://newdomain.com'
  4. Step 4: Replace the old address in the content

    Links and image URLs in posts, widgets and theme settings still use the old domain. Do not run a plain SQL REPLACE: WordPress stores some settings as serialised PHP, which records each string's length, and changing the text without the length corrupts them. WP-CLI's search-replace handles this. Skip the guid column — post GUIDs are identifiers and should not change.

    wp search-replace 'https://olddomain.com' 'https://newdomain.com' --skip-columns=guid --dry-run
    wp search-replace 'https://olddomain.com' 'https://newdomain.com' --skip-columns=guid
  5. Step 5: Flush what is cached

    Re-save Settings → Permalinks, then purge the page cache and any CDN. Cached pages still contain the old links.

  6. Step 6: Redirect the old domain permanently

    Keep the old domain pointing at the server and send every path to the same path on the new one with a 301. If the old domain was in Google Search Console, use its Change of Address tool as well.

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

The mistake people make

Running a find-and-replace in SQL or a text editor on the database dump. Serialised values whose length changed stop loading, and widgets, menus and theme settings silently reset to defaults.

Stuck on something not covered here?

Support is included on every plan, and it reaches a person. There is also the blog for the why behind these, and the FAQ for questions about buying.

Get help

A plan that still makes sense in year two

Free migration, free SSL and daily backups on every plan, with a 30-day money-back guarantee.

Prefer the phone? (305) 671-1272 · Existing customer? Client login