www-Subdomain und Hauptdomain auf andere Subdomain umleiten

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.tld$ [NC]
RewriteRule (.*) https://sub.domain.tld/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ [NC]
RewriteRule (.*) https://sub.domain.tld/$1 [R=301,L]