subdomain – How can I assign a custom url on my domain to users who join my site?

I have a site that offers a subscription service.
I want to assign a custom url to my customers as I have seen some services do.

For example, if my domain name is and my customer url name is ‘customer1’, how can I make a custom url as follows:

I have seen a site that des this and would like to replicate the same.