I've seen many web applications being built now that create a
subdomain on the fly when the user creates their account. I'd like
to figure out how to do this and how to point the subdomain to the
proper database record.
For example, Joe Smith creates an account using an online
form. A subdomain would be created dynamically using the username
Next, when a user enters that url (jsmith.mysite.com) in the
browser, I need to be able to direct him to the proper homepage (my
CF page would need to pick off the "jsmith" in the url). Is there a
way to do that? (hundreds of users would be sharing the same
index.cfm page but the look would be different depending on their
I have seen companies with server software like Plesk that
allow me to create a subdomain dynamically using an API but I'm not
quite sure how that would work.
Another solution that came to mind was to change the DNS with
my hosting provider to wildcard A mysite.com so it would something
like * A 111.222.333.444 (only slightly familiar with this)
That way, with a wild card, anything in front of mysite.com
would be directed to my CF index page. On that page I guess I'd
need some sort of sniffer to be able to read the username that's in
front of mysite.com.
If you get the wildcard thing working, you can look at CGI
variables to get the sub-domain - I can't remember the exact name
of the one you want, but do <cfdump var="#CGI#"/> and it
should be easy to spot.
Wouldn't it be a lot easier to just create a cookie or maybe
link the account to a database variable. That way, when the user
returns, you can simply grab the cookie or do a quick search on the
database (sort of like logging in) and format the index.cfm page
according to his preferences.