How do I point a second domain to a sub web using Cold Fusion?

Using Cold Fusion code you can detect which URL a person is browsing your site with and redirect them to a specific folder. Below is an example that would need to be placed at the top of your default ColdFusion page in the root of your site. (Note: use caution if placing it in an application.cfm file)

<cfif cgi.server_name IS "domain2.com">
  <cflocation url="directory2" addtoken="no">
<cfelseif cgi.server_name IS "domain3.com">
  <cflocation url="directory3" addtoken="no">
<cfelseif cgi.server_name IS "domain4.com">
  <cflocation url="directory4" addtoken="no">
</cfif>

For faster performance, you can use cfswitch syntax as below.

<cfswitch expression="#cgi.server_name#">
  <cfcase value="domain2.com">
    <cflocation url="directory2" addtoken="no">
  </cfcase>
  <cfcase value="domain3.com">
    <cflocation url="directory3" addtoken="no">
  </cfcase>
  <cfcase value="domain4.com">
    <cflocation url="directory4" addtoken="no">
  </cfcase>
</cfswitch>

Add Feedback