0

Not sure if this is controlled in ColdFusion Application.cfm in root directory or through the IIS webserver.

But I am trying to setup multiple subsites off of 1 Root Website using the same ColdFusion code, then setting a distinct data source by sniffing the URL ie: www.root.com/bob and using cgi.http_host.

So I can use the same code and different URL such as:

      www.root.com
      www.root1.com
      www.root2.com

But I need to setup a separate site each time in the webserver (that is fine and understood).

But I would like to run the same code on same root website but on a subdirectory. So I'd like to run:

      www.root.com/test
      www.root.com/test2
      www.root.com/test3
      www.root.com/newsignup

And all these subdirectories can then run the same code, without having to setup multiple websites in IIS.

Is this easily done using ColdFusion? or is it all IIS mapping?

Merle_the_Pearl
  • 1,391
  • 3
  • 18
  • 25
  • The part about having a datasource depend on a cgi variable can easily be accomplished in your application file. Having every site run the exact same code sounds tricky but you appear to have that part figured out. – Dan Bracuk Jul 25 '20 at 16:52

1 Answers1

2

Your code is located somewhere like

E:\path\to\wwwroot

In IIS, you have a site setup with that folder as web root. That site has a primary domain

www.someDomain.com

Then you want to serve the same code under different domains:

In IIS, you'll have to set these up as domain aliases for your site. Look for "Bindings" in IIS Manager. You can also do this by editing the website.config file that will be created in your web root.

If you need different settings to be loaded per domain, you'll have to update your application. I usually set up database tables that map a list of those domains to their settings. That way you can lookup by cgi.http_host to find and cache settings.

<cfif !structKeyExists(application.settings, cgi.http_host)>
    <!--- Look up settings, then cache them here. --->
    <cfset application.settings[cgi.http_host] = ...>
</cfif>

Now you can reference settings per domain throughout the same code base.

Adrian J. Moreno
  • 14,350
  • 1
  • 37
  • 44
  • It's same domain but subdirectories. So.. yes www.somedomain.com is main code. But same code on.. www.somedomain/bob www.somedomain/Carl www.somedomain.com/Fred – Merle_the_Pearl Jul 25 '20 at 00:51
  • Use a URL rewrite in IIS then. So don't create those subdirectories, instead add a rewrite rule for each one pointing to the root, and passing a parameter which you can check for in the CF code to see which path was originally requested. – Sev Roberts Jul 27 '20 at 10:01