Use CGI.HTTP_HOST
Issue: mydomain.com gets load-balanced and uses multiple servers. CGI.SERVER_NAME will not return ‘mydomain’ but will return ’sever1′ or ’server2′ etc.
I want to check the request URL, and if it does not include www, re-locate to www.mydomain/pagerequested?event=eventrequested
<cfset secureurl = xmlParse(expandPath("/mydevenvironment/settings.xml")).
settings.secureHost.xmlText />
<cfloop collection="#CGI#" item="field">
<cfoutput>#field#: #CGI[field]# <BR></cfoutput>
</cfloop>
<cfif NOT REFind("www\.", CGI.HTTP_HOST)>
<cfif CGI.HTTPS EQ "on">
<cfset theURLBase = secureurl />
<cfelse>
<cfset theURLBase = REREplace(secureurl,"https:","http:")/>
</cfif>
<cfoutput>#theURLBase#</cfoutput>
<cflocation url='#theURLBase##CGI.SCRIPT_NAME#?#CGI.QUERY_STRING#'addtoken="false">
</cfif>