Skip to main content
December 8, 2009
Answered

Administer Subdomains

  • December 8, 2009
  • 1 reply
  • 673 views

Can coldfusion create subdomains?  I want to set up an administrator panel which allows a client to create subdomains on the server and point them to root directories for individualized 'child' sites.  Or point all subdomains to the same root, but have CF output tailored to data specific to each subdomain.

Also a factor, Can this be done in a 3rd party hosting environment?  Thank you to all those who reply.

    This topic has been closed for replies.
    Correct answer ilssac

    The basic idea to serve up different content based on domain:

    First you would use the cgi <cfdump var="#cgi#"> data to determine what domain the request is comming from.

    Then either in an Applicaiton.cfm or the more modern Application.cfc OnRequestStart() method to branch your code.

    A basic switch case block is pretty good at handling something like this.

    <cfswitch expression="#domainData#">

      <cfcase value="subdomainOne">

        .....

       </cfcase>

       <cfcase value="subdomainTwo">

       ....

       </cfcase>

    <cfswitch>

    But there are other ways to handle this as well.

    1 reply

    ilssac
    Inspiring
    December 8, 2009

    ColdFusion doesn't have anything to do with domains at all.

    If you know how to administer domains with command line syntax, then <cfexecute....> most likely can execute the same commands.

    As for servering up different content base on Domains, ColdFusion can do this easily.

    What you can do on the 3rd party hosting enviornment is what they let you do.  So you would have to ask each one you are considering what they support.

    December 9, 2009

    something like this?:

    <cfexecute   name="c:\winnt\system32\cmd.exe"   arguments="/C netstat -n"   timeout="5"> </cfexecute>

    or with code from the following command-line code examples listed in the 'arguments' attribute?

    To create subdomain subdom on domain example.com:

    # ./subdomain --create subdom -domain example.com

    or

    # ./subdomain -c subdom -domain example.com

    Also, any suggestions (I've never done it) on how to serve up different content base by domain?  The subdomains will be added progressively as the organization grows so the code must be flexible enough to feed data for new subdomains on the fly.

    Thanks! 

    Participant
    December 9, 2009

    Isn't this a bit like asking Microsoft Paint to create Windows user accounts?