Skip to main content
Inspiring
February 28, 2008
Answered

Automated method to create subsites

  • February 28, 2008
  • 2 replies
  • 567 views
We are creating subsites by creating new subdirectories and using a separate application.cfm and include files.
www.mysite.com/subsite1
www.mysite.com/subsite2

Is there a way in coldfusion to automate this? I.e., map "subsite1", "subsite2", ... to a database column to determine which rows/content to render. The part that is unclear is how to capture the subdirectory and map it to a database column even if the subdirectory doesn't exist.
This topic has been closed for replies.
Correct answer Neo Rye
I'd do it differantly. Set up your DNS to point all (any) hosts to your domain, so someone could type anything as the host such as subsite1.mywebsite.com and subsite2.mywebsite.com. Then you only need one application.cfm where the name of the application is the domain name with cgi.server_name. You then define your sites in the database based on their unique URL. This is also handy if you need to break your busy sites accross multiple jrun instances or servers.

You could then apply differant layout per application and differant config, directories etc. You can look at fusebox 5, since that framework can apply layouts based on variables.

2 replies

Neo RyeCorrect answer
Inspiring
February 28, 2008
I'd do it differantly. Set up your DNS to point all (any) hosts to your domain, so someone could type anything as the host such as subsite1.mywebsite.com and subsite2.mywebsite.com. Then you only need one application.cfm where the name of the application is the domain name with cgi.server_name. You then define your sites in the database based on their unique URL. This is also handy if you need to break your busy sites accross multiple jrun instances or servers.

You could then apply differant layout per application and differant config, directories etc. You can look at fusebox 5, since that framework can apply layouts based on variables.
jaliuAuthor
Inspiring
February 28, 2008
Yes, this appears to work better. Using the cgi.servername I can get the subsite and use that in the query. Thanks!
Prasanth_Kumar_S
Inspiring
February 28, 2008
Hi,
You can use the CGI.SCRIPT_NAME variable and use the listfirst function to get the text you require.

-Prasanth
jaliuAuthor
Inspiring
February 28, 2008
Thanks, I think that provides the solution. It appears subsites can be automatically created with the cfdirectory (create) and cffile (copy) to move stub/empty files over. The stub/empty files would just contain includes bringing in the original templates and specify which database rows to retrieve based upon the CGI.SCRIPT_NAME variable. This appears to work, but is there a better way to accomplish this?