So, login to your host. I tend to do everything as root because I’m lazy. But if you don’t, you’ll need to sudo all these commands. Something like this:
then inside that, you’d put something like:
I also tend to add this:
Redirect /index.php http://newsite.com
because “www” is so 1990s, but there are internet SEO bros out there who think they know it all and insist that websites start with “www” lol.
Anyway, make sure that DocumentRoot points at your existing Wordpress directory.
service apache2 reload
From there, you can go into Wordpress and change the “Wordpress Address” and “Site Address” in “Settings” in the Wordpress admin panel to point at the new URL. If you can’t get in for some reason, try going to the old site and changing from there. Or you’ll perhaps have to change it in the database itself.
Then just use the site for a while to make sure the new address works, perhaps do the SSL stuff with certbot, etc.
Once you have all that done, go back and edit the old site’s config.
And add a redirect to the new site
Something like this:
Redirect /index.php https://newsite.com
And reload apache again, and it should redirect to the new one.
If you run into trouble, let me know!