Changing WordPress site URL or hosting folder safely

wordpressmigrationapachehosting

Changing a site path or domain impacts WordPress, Apache, and SSL. Plan the order of operations and have a backup.

Prerequisites

Update URLs

Prefer WP-CLI:

wp search-replace 'old-url' 'new-url'

Update Apache vhost

Ensure docroot points to:

/var/www/<site-root>

Reload Apache after changes: fixing Apache restart failures if something fails.

High-risk SSL warning

Deleting certificates incorrectly can break multiple sites. Before changing anything:

sudo certbot certificates

If you use Cloudflare in front, align SSL mode and WordPress URLs to avoid redirect loops.