I have the domain www.mysite.com. This is what I ultimately want to do with it:
On the site www.mysite.com, there will be a marketing website for my website/product (I'll call it the "software"), and a registration form. When registering, a customer specifies what subdomain they want to use, so say their company is XYZ Company, they would choose a subdomain of "xyz".
Somehow, the url xyz.mysite.com is then able to run the code for my software.
My software will inspect the domain name for each request, and extracts the subdomain value, i.e. "xyz". It uses this to set the connection string, i.e. to use database "xyz", and so that customer gets access to his data.
That's essentially it. A couple of things, though:
I only want to have 1 copy of the code. All the subdomains should effectively "rewrite" the request to this central copy of the code, as the code will be identical across clients/subdomains.
Ideally, although this is not essential, I hoped I would be able to 'wildcard' the A record (or CNAME record, or whatever), so that I didn't need to make any further DNS modifications whenever a client registered - i.e. EVERY & ANY value in the subdomain, would rewrite to the single code folder. I would check when the client requests the login page if that subdomain had been registered, and return 404 if not.
How do I achieve this? What combination of DNS records or aliases or subdomains do I need?