• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Creating and using subdomains

New Here ,
Apr 25, 2006 Apr 25, 2006

Copy link to clipboard

Copied

Hi all,

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 he selected: http://jsmith.mysite.com

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 username)

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.

Any ideas?
TOPICS
Advanced techniques

Views

271

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 25, 2006 Apr 25, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 26, 2006 Apr 26, 2006

Copy link to clipboard

Copied

LATEST
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation