Creating a dev site on subdomain with live site at root in Drupal 9 and Drupal 7

I need to have a copy of my live site install in a subdomain called dev.mydomain.com. But when I connect to that subdomain, the site shown is the one at the main domain, although the url contains the subdomain.

I imagine I need to configure the .htaccess files at both installations properly. Can anyone help me with the right configuration?