Change a WordPress site's URL

url, siteurl, home, search-replace, wp-cli, https, domain · 0 found this helpful

WordPress remembers its own address in the database. When your domain changes, or you move to HTTPS or from www to non-www, you must update it, or links, images, and the login page break.

Before you start

Method 1: Settings screen

If wp-admin works:

  1. Go to Settings → General.
  2. Change WordPress Address (URL) and Site Address (URL).
  3. Click Save Changes. You'll be signed out.

Method 2: wp-config.php (when you're locked out)

Add above the line /* That's all, stop editing! */:

define( 'WP_HOME',    'https://example.ca' );
define( 'WP_SITEURL', 'https://example.ca' );

These values override the database. Remove them after you fix the settings, or keep them to lock the address.

Method 3: WP-CLI (best for a full change)

Pages, widgets, and plugin settings often store the old URL too. A search-replace fixes all of them, including serialized data.

cd ~/public_html

# 1. Preview. Nothing changes.
wp search-replace 'https://old.example.ca' 'https://example.ca' --dry-run

# 2. Make the change
wp search-replace 'https://old.example.ca' 'https://example.ca' --skip-columns=guid

# 3. Clear caches
wp cache flush
wp rewrite flush

Don't use a plain SQL REPLACE, which breaks serialized values. See Use WP-CLI.

Method 4: phpMyAdmin

Run only if WP-CLI isn't available.

  1. Open the wp_options table. See Use phpMyAdmin.
  2. Edit siteurl and home.
  3. Use WP-CLI or a plugin such as Better Search Replace for the rest.

After the change

  1. Add a 301 redirect from the old domain. See Redirect a page or domain.
  2. Regenerate SSL if the host name changed. See Free SSL with AutoSSL.
  3. Clear LiteSpeed Cache. See Speed up WordPress.

If something goes wrong

  • Redirect loop after the change: the old address is still set in WP_HOME or .htaccess.
  • Images missing: some URLs still use the old address. Run the search-replace again.
  • Theme settings reset: you used a replace that broke serialized data. Restore the backup and use WP-CLI.

Was this helpful?

Still stuck? Ask us and we'll walk you through it.