How to switch subdomain with root domain and redirect traffic?

You can redirect all old inner pages to the new ones using .htaccess with HTTP header 301, but remember not to duplicate on the new site these parts of old URLs which goes after the old domain name (like /new-page-1/ in the example below).

RewriteEngine On
Redirect 301 /old-page-1/ httр://sub.domain.tld/new-page-1/
Redirect 301 /old-page-2/ httр://sub.domain.tld/new-page-2/

You can’t do this with the main page. And you’ll have to wait a week or more for search engines to reindex everything.