Rebranding, buying the .com at last, or moving from a subdomain to the root: at some point a site needs a new address. WordPress stores its URL in hundreds of places, and a rename done by find-and-replace on a database dump corrupts some of them. Here is the safe sequence, and the part most guides skip — what to do about the old domain so you keep your rankings.
Before
- Add the new domain to the same hosting account (Plesk: Add Domain, or add it as an alias if the files should stay where they are).
- Issue an SSL certificate for the new domain.
- Take a full backup — files and database.
- If the site is large, put it in maintenance mode for the ten minutes this takes.
1. Point the files
Either move the site's files into the new domain's document root, or — simpler on Plesk — set the new domain's document root to the existing directory under Hosting Settings. WordPress Toolkit's Clone to the new domain, followed by deleting the old, is another route that handles the URL change for you; if you use it, skip to step 4.
2. Change the URL in WordPress
Two settings: Settings → General → WordPress Address and Site Address. Change both to https://new-domain.com and save. You will be logged out; log in at the new address. If the admin is unreachable, set them in wp-config.php temporarily:
define('WP_HOME', 'https://new-domain.com');
define('WP_SITEURL', 'https://new-domain.com');3. Search-replace the database — properly
Post content, widgets, theme options, page builder data and menus all contain the old URL, and many are stored serialised — PHP arrays with string lengths embedded. A plain SQL REPLACE() changes the string but not the length, and the option becomes unreadable. Use a tool that understands serialisation:
WP-CLI (available on VPSPioneer plans and most servers):
cd /var/www/vhosts/new-domain.com/httpdocs
wp search-replace 'https://old-domain.com' 'https://new-domain.com' --all-tables --dry-run
wp search-replace 'https://old-domain.com' 'https://new-domain.com' --all-tables
wp search-replace 'old-domain.com' 'new-domain.com' --all-tables # catches protocol-less references
wp cache flushThe dry run shows counts per table; the real run applies them. Without WP-CLI, the Better Search Replace plugin does the same from the admin with a dry-run option.
4. Fix what the search-replace does not reach
.htaccess/ Nginx rules with hard-coded domains.- Uploaded files in
wp-config.phpor theme code with the old domain literal. - Hard-coded URLs in CSS (
url(https://old-domain.com/...)) — grep the theme. - Third-party services keyed to the domain: payment gateways, analytics property, Facebook pixel, reCAPTCHA keys, plugin licences, email service sender domains, CDN.
- Permalinks: Settings → Permalinks → Save once, to regenerate rewrite rules.
5. Redirect the old domain — every URL
This is what preserves search rankings and inbound links. Every old URL must 301 to the same path on the new domain — not to the homepage. On the old domain's hosting (keep it for at least a year):
# .htaccess on old-domain.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]# Nginx
server {
listen 443 ssl;
server_name old-domain.com www.old-domain.com;
# ssl_certificate lines...
return 301 https://new-domain.com$request_uri;
}Keep a certificate on the old domain so https://old-domain.com/page redirects rather than warns. Plesk's Hosting Settings → Forwarding (301, keep path) does this from the panel.
6. Tell the search engines
- Google Search Console: verify the new domain, then on the old property use Settings → Change of address. This tells Google to move signals to the new domain and speeds up the transition considerably.
- Submit the new sitemap.
- Bing Webmaster Tools: Site Move under the old site's configuration.
- Update the URL in your Google Business Profile, social profiles, and email signatures.
Expect rankings to wobble for two to six weeks and then settle at or near the old level, provided every URL redirects one-to-one.
7. Verify
- Load a dozen old URLs and confirm each 301s to its exact counterpart:
curl -sI https://old-domain.com/some/page | grep -i "location". - Search the new site's HTML for the old domain:
wp search-replace ... --dry-runagain should show zero, andgrep -r "old-domain" wp-content/themes/should be empty. - Check mixed-content warnings in the browser console — old
http://references that slipped through. - Test the contact form and any checkout end to end.
If the old domain handled email, keep its mailboxes alive with forwarding for a year and put an auto-reply on key addresses. Moving the mailboxes themselves is a separate job: migrating email between hosts.
A domain change is included in a VPSPioneer free migration when you move to us — the search-replace, redirects and Search Console change are all part of the checklist.