Skip to content

Moving a single WordPress off cPanel without touching DNS

When one WordPress site has to move but DNS belongs to a department you cannot reach, the cutover happens with a hosts-file preview and a coordinated A-record flip.

Sometimes the situation is: the marketing site lives on cPanel, the DNS is managed by a department that takes a week to make changes, and the move has to land before the next campaign. The trick is to validate the destination so thoroughly with a hosts-file preview that the DNS change becomes a non-event — five minutes of attention and zero rollback chance.

What’s happening

WordPress hardcodes the site URL in wp_options (siteurl, home) and in serialized post content. Any preview path that uses a different hostname has to either rewrite those values at request time or accept that all internal links point at the old site. The cleanest preview is one where the destination thinks it is the production site, but only your laptop’s DNS resolves to it — done with a hosts-file override.

How to verify

On the cPanel source, capture the WordPress baseline:

mysql -uroot -e "SELECT option_value FROM <db>.wp_options WHERE option_name IN ('siteurl','home');"
du -sh /home/<user>/public_html/wp-content/uploads
ls -1 /home/<user>/public_html/wp-content/plugins | wc -l

On the destination, override DNS locally and validate:

# /etc/hosts on your laptop
<dest-ip> example.com www.example.com
# then in a browser, hit https://example.com — should serve from destination
curl -k -H "Host: example.com" https://<dest-ip>/wp-admin/admin-ajax.php?action=heartbeat

The fix

  1. Build the destination — provision the target host, install matching PHP/MySQL versions, deploy the WordPress codebase (rsync from /home/<user>/public_html/), restore the database dump.
  2. No URL rewrite — leave siteurl and home as the production URL. The site only resolves to the destination via your hosts file at this stage.
  3. Validate against production hostname — add <dest-ip> example.com to your hosts file, browse the site, log in, click through templates, check admin functions. Anything broken now will be broken after cutover.
  4. Issue the certificate in advance — Let’s Encrypt via DNS-01 challenge works without changing the live A record. The destination will serve a valid cert from the moment DNS flips.
  5. Cutover — submit the A-record change ticket with a 300-second TTL. When the change lands, monitor tail -f /var/log/nginx/access.log on the destination. Roll back by reverting the A record; the destination keeps serving via hosts-file testing.

If WordPress uses absolute URLs in content, run a search-replace with WP-CLI (wp search-replace) only after DNS has flipped — never before, or hosts-file preview breaks. Stack Harbor handles single-site cutovers under migration solutions — book a migration review when DNS is owned by someone else.