AngeloS
AngeloS

Reputation: 5586

Get a subdomain of a URL using ColdFusion

How can I get the subdomain of a URL using Coldfusion?

For example, say I had the following URL:

http://support.foo.com

How could I get 'support'?

Is there a built in function to do this?

Upvotes: 4

Views: 1608

Answers (1)

James Hill
James Hill

Reputation: 61842

Here's the basic idea:

<cfset domain = cgi.server_name>
<cfset subDomain = "">

<cfif ListFirst(domain, ".") neq "foo" and ListFirst(domain, ".") neq "www">
    <cfset subDomain = ListFirst(domain, ".")>
</cfif>

Upvotes: 7

Related Questions