ColdFusion code to get current Domain
Below simple function can be used to find the current domain, by calling this wherever required.
<cfreturn domain />
<cffunction name="GetCurrentDomain" access="public" output="false" returntype="string"
hint="Get Current Domain">
<cfset domain="" />
<cfset proto ="http" />
<cfif CompareNoCase(CGI.HTTPS , 'on') EQ 0>
<cfset proto = "https" />
</cfif>
<cfset domain = proto&'://'&CGI.server_name&'/' />
<cfset proto ="http" />
<cfif CompareNoCase(CGI.HTTPS , 'on') EQ 0>
<cfset proto = "https" />
</cfif>
<cfset domain = proto&'://'&CGI.server_name&'/' />
<cfreturn domain />
/cffunction>
Comments
Post a Comment