How to make a custom subdomain

Hello,

can someone help me in this case?

I have below things:

Main domain: www.domainname.com
Sub Domain for Backend Link: login.domainname.com

What I am looking for is.

username.domainname .com should redirect to login.domainname .com where username can be a user who wants to log in. This is Business to Business Application.