Skip to content

Renaming a cPanel account — what happens to the zone

Renaming a cPanel account or changing the primary domain rebuilds the zone files in subtle ways. Here is what changes, what survives, and what to verify.

A reseller’s customer changes their primary domain from oldname.com to newname.com. Both belong to the same cPanel account; the customer doesn’t want to migrate to a new account, just swap the primary. cPanel has a “Modify an Account” feature for this. After the swap, the customer’s website loads, but some DNS records — DKIM, custom TXT for SaaS verifications, NS records on subdomains — disappear or change. The rename does more than rename.

What’s happening

When you change a cPanel account’s primary domain (WHM > Account Functions > Modify an Account), several things happen:

  • The cPanel user’s home directory may or may not be renamed (a separate step).
  • /etc/userdomains and /etc/userdatadomains are updated.
  • The old primary’s zone file is unchanged, but the account’s “primary” zone becomes the new domain.
  • The new primary’s zone file is created if it doesn’t exist; if it does exist (parked or addon on another account), cPanel may refuse.
  • Mail accounts under the old primary are renamed in the file structure (/home/user/mail/oldname.com → /home/user/mail/newname.com).
  • DKIM keys are regenerated for the new primary; the new public key has to be republished in DNS.
  • Any addon domains on the account stay where they were.

The non-obvious effects:

  • The new primary’s zone is created from cPanel’s default template, which may not include the customer’s custom TXT records or SaaS verifications. Those have to be re-added.
  • DKIM for the old primary is gone or stale; the new primary has a fresh key that needs the matching DNS record.
  • Subdomains that were under the old primary (blog.oldname.com) are not automatically moved or aliased to the new (blog.newname.com). They have to be re-created.
  • If the customer had cPanel’s autoresponders or forwarders configured, mail rules tied to oldname.com continue to work for any mail still routed to that domain — but new rules for newname.com need to be created.

How to verify

Before the rename, capture state:

whmapi1 dumpzone domain=oldname.com > /tmp/oldname-zone-before.txt
whmapi1 dumpzone domain=newname.com > /tmp/newname-zone-before.txt 2>/dev/null
ls /home/user/mail/

After the rename:

whmapi1 dumpzone domain=oldname.com > /tmp/oldname-zone-after.txt
whmapi1 dumpzone domain=newname.com > /tmp/newname-zone-after.txt
diff /tmp/oldname-zone-before.txt /tmp/newname-zone-before.txt
diff /tmp/oldname-zone-after.txt /tmp/newname-zone-after.txt

Look for custom TXT records that may have been lost. Common ones:

dig +short TXT newname.com | grep -i 'verification\|spf\|dmarc'
dig +short TXT default._domainkey.newname.com

Confirm mail delivery to the new primary works:

exim -bt test@newname.com
swaks --to test@newname.com --server localhost --quit-after RCPT

What to do

  1. Decide if a rename is the right operation. Often a cleaner alternative is to add newname.com as an addon on the same account and keep oldname.com as the primary (or vice versa). Renames are blunt; addons are surgical.
  2. Inventory the existing zone before the rename. Save whmapi1 dumpzone output for both old and new domains. Any record you can’t recreate from this dump is lost.
  3. Perform the rename in WHM > Account Functions > Modify an Account. Set the new primary domain.
  4. Republish DKIM for the new primary. WHM > Email Deliverability > DKIM for the new account, generate, install in DNS.
  5. Re-add SaaS verifications. Google Search Console, Microsoft 365 tenant verification, Facebook business verification, any other service that issued a TXT — re-publish each.
  6. Recreate subdomains under the new primary if they existed under the old. The Subdomains tool in cPanel does this.
  7. Update external systems — anything that referenced oldname.com (DNS at customers of yours, third-party API integrations) needs updating. The rename doesn’t propagate outward.
  8. Set up a permanent redirect from oldname.com to newname.com if the customer wants to retire the old domain entirely. The redirect lives in the web server config (Apache mod_rewrite or LiteSpeed equivalent), and the DNS for oldname.com should still resolve to the cPanel host for the redirect to work.
  9. Decide on the old domain’s mail. If oldname.com is being retired, set up mail forwarders from *@oldname.com to *@newname.com (or to whatever the customer prefers). Without forwarders, mail to the old domain bounces.

Document the rename. Six months later, when someone asks “why does the SaaS verification TXT for our old domain still exist?” the answer should be in your runbook, not in nobody’s head.

Stack Harbor handles cPanel account renames including DNS hygiene as part of cPanel/WHM management.