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
- Build the destination — provision the target host, install matching PHP/MySQL versions, deploy the WordPress codebase (
rsyncfrom/home/<user>/public_html/), restore the database dump. - No URL rewrite — leave
siteurlandhomeas the production URL. The site only resolves to the destination via your hosts file at this stage. - Validate against production hostname — add
<dest-ip> example.comto your hosts file, browse the site, log in, click through templates, check admin functions. Anything broken now will be broken after cutover. - 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.
- Cutover — submit the A-record change ticket with a 300-second TTL. When the change lands, monitor
tail -f /var/log/nginx/access.logon 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.