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.
prasanth25 - 28 Feb 2008 08:46 GMT
Hi,
You can use the CGI.SCRIPT_NAME variable and use the listfirst function to get the text you require.
-Prasanth
jaliu - 28 Feb 2008 19:34 GMT
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?
GArlington - 28 Feb 2008 09:42 GMT
> We are creating subsites by creating new subdirectories and using a separate
> application.cfm and include files.
[quoted text clipped - 5 lines]
> 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.
If you DO NOT want to create new subdirs all the time, you can use URL
re-writing to redirect requests to one main dir, i.e. /subsite(\d*) -
> /subsites/?siteID=$1.
If you want to serve different content from this directory to
different subsites, then all you have to do is to check cgi vars for
the address...
jaliu - 28 Feb 2008 19:44 GMT
Yes, this appears to work better. Using the cgi.servername I can get the subsite and use that in the query. Thanks!