Redirect Specific Wildcard Subdomain to a specific URL on another domain

You can do something like the following at the top of your .htaccess file in the document root using mod_rewrite before the WordPress front-controller.

Note that since you have two distinct patterns (root directory to /music and everything else to the root directory on the other domain) then you’ll need to two rules.

RewriteEngine On

# "music.example.com/" to "another.example/music/"
RewriteCond %{HTTP_HOST} ^music\.example\.com [NC]
RewriteRule ^$ https://another.example/music/ [R=302,L]

# "music.example.com/<something>" to "another.example/<something>"
RewriteCond %{HTTP_HOST} ^music\.example\.com [NC]
RewriteRule (.+) https://another.example/$1 [R=302,L]

The RewriteCond (condition) directive checks the requested host. The RewriteRule naturally redirects to the other domain. In the second rule the URL-path from the request is captured in the $1 backreference.

Note that this is a 302 (temporary) redirect. If this is intended to be permanent, then change to 301 (ie. R=301) but only once you have confirmed that it works OK. 301s can be problematic when testing as they are aggressively cached by the browser.