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
<!--- Redirect to the site that corresponds to the securehost --->
<cfset secureurl="xmlParse(expandPath("/mydevenvironment/settings.xml"))." settings.securehost.xmltext="">
<cfloop collection="#CGI#" item="field">
<cfoutput>#field#: #CGI[field]#
</cfoutput>
</cfloop>
<cfif not="" refind("www\.",="" cgi.http_host)="">
<!--- If a secure request, keep the https, otherwise just go to http--->
<cfif cgi.https="" eq="" "on"="">
<cfset theurlbase="secureurl">
<cfelse>
<cfset theurlbase="REREplace(secureurl,"https:","http:")/">
</cfset></cfelse></cfset></cfif>
<cfoutput>#theURLBase#</cfoutput>
<cflocation url="#theURLBase##CGI.SCRIPT_NAME#?#CGI.QUERY_STRING#" addtoken="false">
</cflocation></cfif>
</cfset>