Change a WordPress site's URL
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
- Take a backup. See Back up and restore WordPress.
- The new domain already points at your hosting. See Host another website with an addon domain.
Method 1: Settings screen
If wp-admin works:
- Go to Settings → General.
- Change WordPress Address (URL) and Site Address (URL).
- 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.
- Open the
wp_optionstable. See Use phpMyAdmin. - Edit
siteurlandhome. - Use WP-CLI or a plugin such as Better Search Replace for the rest.
After the change
- Add a 301 redirect from the old domain. See Redirect a page or domain.
- Regenerate SSL if the host name changed. See Free SSL with AutoSSL.
- Clear LiteSpeed Cache. See Speed up WordPress.
If something goes wrong
- Redirect loop after the change: the old address is still set in
WP_HOMEor.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.
Still stuck? Ask us and we'll walk you through it.