---
title: How to Change Your WordPress Domain Without Losing Traffic
description: "How to change your WordPress domain: update the site address, rewrite stored links, redirect every old URL and tell Google. Tested on WordPress 7.1.4."
url: "https://skybootstrap.com/change-wordpress-domain/"
canonical_url: "https://skybootstrap.com/change-wordpress-domain/"
date: "2026-11-28T06:35:00+06:00"
modified: "2026-11-16T17:22:19+06:00"
author: Skybootstrap Team
type: article
site: SkyBootstrap
language: en-US
---

# How to Change Your WordPress Domain Without Losing Traffic

To change your WordPress domain, point the new domain at your site, update the two address fields, and rewrite the old domain in your database with a search-replace. Then 301-redirect every old URL to the same path on the new domain, and tell Google with Search Console’s Change of Address tool.

We changed the domain of a copy of our test site and counted what each step left behind. The address fields alone missed links in five posts, the search-replace missed one URL saved in escaped form, and WordPress kept serving the old domain until the server redirected it.

## Before you change your WordPress domain

Before you change your WordPress domain, make a fresh backup, point the new domain at your hosting, and put an SSL certificate on both domains. The backup lets you undo the change, and the old domain keeps its certificate so its HTTPS redirect still works. In detail:

- **A backup.** You’re about to rewrite the database. A fresh backup lets you undo the whole change; the commands are in our backup guide.
- **The new domain pointed at your hosting.** Add it to your hosting account and point its DNS at the server. The site should answer on both domains before you start.
- **SSL on both domains.** The new one needs a certificate for `https://`, and so does the old one, or its redirect can’t be served over HTTPS. [Kinsta’s guide](https://kinsta.com/blog/wordpress-change-domain/) says the same: “you’ll also need to keep an SSL cert installed on it”.

If you’re moving to a new host at the same time, do that first with the same domain, using our host migration guide, and change the domain afterwards. One change at a time makes it clear which one broke something.

## Change the site address in WordPress

The Site Address is the domain WordPress puts in every link it builds. It lives in two fields under **Settings > General**: “WordPress Address (URL)” and “Site Address (URL)”, as the [WordPress handbook](https://developer.wordpress.org/advanced-administration/upgrade/migrating/) names them. Change both to the new domain and save; you may be logged out and have to log in again on the new domain. These steps are for a single site: the handbook’s own note says “These directions are for single installs of WordPress only.”

With WP-CLI, the same change is two commands:

```
wp option update home 'https://new-example.com'
wp option update siteurl 'https://new-example.com'
```

That’s not enough on its own: after we changed only these two fields, the homepage had 332 links on the new domain but still one on the old, and five posts still had the old domain in their content. Those are links and image addresses typed or pasted into posts. They’d keep working only as long as the old domain redirects.

## Update stored links with a search-replace

To update stored links, run a search-replace, which is a find-and-replace across the whole database: it finds the old domain anywhere and writes the new one in its place. WP-CLI’s `search-replace` command does it safely, including inside settings stored in PHP’s packed (serialized) format; our [localhost to live guide](https://skybootstrap.com/move-wordpress-from-localhost-to-live/) explains why a plain text replace breaks those. Try it first with `--dry-run`, which only counts:

```
wp search-replace 'https://old-example.com' 'https://new-example.com' --skip-columns=guid --dry-run
wp search-replace 'https://old-example.com' 'https://new-example.com' --skip-columns=guid
```

On our copy, which still had the old address everywhere, it changed 8 values: the two address settings, five posts and one user’s website field. If you’ve already saved the new address in Settings, expect two fewer. The `--skip-columns=guid` part protects one column, the guid. The handbook is firm about that column: “It is critical that you do NOT change the contents of this field.”

One value survived, though. Some page builders and plugins save an escaped URL, which has a backslash before each slash: `https:\/\/old-example.com`. We stored one that way, and the first search-replace didn’t touch it. A second pass with the escaped text did:

```
wp search-replace 'https:\/\/old-example.com' 'https:\/\/new-example.com' --skip-columns=guid
```

That made one more replacement, and nothing of the old domain was left outside the guid column. Here’s what each step left behind on our copy:

| After this step | Old domain left in the database |
| --- | --- |
| Settings > General only | 5 posts and 1 escaped value |
| Plus search-replace | 1 escaped value |
| Plus the escaped pass | None outside the guid column |

Run both passes for `http://` too if your site ever used it, and for `www.` if the old domain had it. We tested one page-builder-style value we added by hand, not a page builder itself. WP-CLI searches only the tables WordPress knows about, so add `--all-tables-with-prefix` if plugins created their own; on our copy, a check of the whole database found the old domain nowhere else.

Without SSH, cPanel’s Terminal (if your host enables it) or a plugin that handles serialized data, such as Better Search Replace, can do this step. We didn’t test either.

## Set up a 301 redirect for every old URL

A 301 redirect is a permanent redirect: it tells browsers and search engines that a page has moved for good, and where to. Each old URL should go to the same path on the new domain, not just to the homepage.

Don’t count on WordPress to do it: when we pointed the old domain at the same WordPress install without a redirect rule, every page we tried answered on the old domain with 200, the normal “OK” status. WordPress only switches between `www` and non-`www`; its own code says “Only redirect no-www <=> yes-www.”

Its canonical tag did point at the new domain, but that’s a hint to search engines, not a redirect for visitors. So redirect at the server:

![Change WordPress domain diagram: with a server 301 rule, each old URL goes to the same path on the new domain; without one, the old domain keeps serving the pages itself](https://skybootstrap.com/wp-content/uploads/2026/11/change-wordpress-domain-redirect.webp "Old domain with and without a server redirect, from our tests on WordPress 7.1.4, 11 Nov 2026.")

On nginx, first remove the old domain’s names from your site’s own `server_name` line. Then give the old domain its own server blocks, one for `http` and one for `https`:

```
server {
listen 80;
server_name old-example.com www.old-example.com;
return 301 https://new-example.com$request_uri;
}
server {
listen 443 ssl;
server_name old-example.com www.old-example.com;
# ssl_certificate lines for the old domain go here
return 301 https://new-example.com$request_uri;
}
```

Run `nginx -t`, then reload nginx. When we left the old name in the site’s block as well, `nginx -t` warned “conflicting server name … ignored”, and which block wins then depends on the order nginx reads its files.

`$request_uri` carries the path and query string across. Our lab ran plain `http` on its own port, and there the homepage, a post, a search, the login page and the feed each went to the same address on the new domain in one redirect. We didn’t test the `https` block.

On Apache, the usual rule goes at the very top of the old domain’s `.htaccess` file, above `# BEGIN WordPress`. On many hosts both domains share one folder, so that’s the same file your site uses. We didn’t test this rule:

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

Without access to either file, use your hosting panel’s redirect tool and choose a permanent (301) redirect that keeps the path; in cPanel’s Redirects tool, that’s the “Wild Card Redirect” option, which we didn’t test. Then test a few old addresses with `curl -sI https://old-example.com/some-post/` and check for `301` and the right `Location`. If you get a loop, our [redirect loop fixes](https://skybootstrap.com/wordpress-too-many-redirects/) help.

## Tell Google with Search Console’s Change of Address tool

The Change of Address tool in Google Search Console tells Google that your site moved to a new domain. [Google’s help page](https://support.google.com/webmasters/answer/9370220) says to use it after the move and the redirects are done. We couldn’t test it in our lab, so this section follows that page.

- **Verify both domains** in Search Console with the same Google account: “You must use the same Google account to manage both properties.”
- **Redirect first.** The tool expects a 301 from the old homepage to the new one, so set up the redirects above before you use it.
- **Submit for every version** of the old domain, `www` and non-`www`, and verify each one first. The tool works on whole domains only, not folders.
- **Keep the redirects.** Google forwards signals to the new site for 180 days. Its advice: “Maintain the redirects for at least 180 days–longer if you still see any traffic to them from Google Search.” It also suggests keeping the old domain registered for at least a year.

Then submit the new domain’s sitemap in Search Console. Kinsta goes further and says you can “leave this redirect in place forever”.

Change the address anywhere else that stores it too: Bing Webmaster Tools, your analytics property, and any cache or CDN that served the old domain. We didn’t test those.

## Locked out after changing the address? Fix it

If you saved a new address before the new domain reached your site, WordPress sends you to that domain to log in, and you’re locked out. In our test, the login page redirected to the unreachable domain, and the homepage held 331 links to it.

With WP-CLI, fix the stored address directly with the two `wp option update` commands above, using the domain that works now. That worked at once for us.

Without WP-CLI, set the address in wp-config.php instead. Add these two lines above the line that says “That’s all, stop editing!”:

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

Use the domain that works right now. On our test site, a check made straight after the edit still redirected, and one three seconds later reached the login page on the working domain.

The lines override the database without changing it, and while they’re there, WordPress greys out both address fields in Settings > General. The handbook says as much: “You won’t be able to edit them on the General settings page anymore when using this method.” You can leave the lines in place for good.

To go back to the database value, correct the `home` and `siteurl` rows in the `wp_options` table with phpMyAdmin, then remove the lines. Don’t use `wp option update` while the lines exist: ours reported the value “unchanged” and left the wrong address stored. For other reasons you can’t log in, see our wp-admin lockout fixes.

Once everything works on the new domain, the WordPress maintenance checklist covers the routine checks from here.

## How we tested

For this test, a copy of our WordPress 7.1.4 lab site went into a separate folder and database, with an “old” and a “new” domain on our lab server. Every change ran through WP-CLI 2.12.0. We counted what was left after changing only the settings, after a search-replace and after an escaped pass.

We then tested an nginx 301 rule against no rule, and a lockout fixed two ways. Real DNS, SSL, Apache rules, a page builder and the Search Console tool were outside the test.

## Frequently Asked Questions

### Will changing my WordPress domain hurt SEO?

Changing a domain can cost traffic while search engines catch up; we haven’t measured rankings through a move ourselves. Google says it forwards signals from old to new URLs for 180 days after a Change of Address, so keep every old URL redirecting to the same page.

### How long should I keep the old domain redirecting?

Keep the old domain redirecting for at least 180 days, Google’s minimum, and longer if Search Console still shows visits to the old URLs. Google also suggests keeping the old domain registered for a year.

### Should I change the guid column?

The guid column should never change. WordPress uses it as each post’s permanent identifier, which feed readers rely on, and the handbook says “It is critical that you do NOT change the contents of this field.” `--skip-columns=guid` keeps the search-replace away from it.