title: Extracting the Domain from the URL using ColdFusion
body: <p>I am currently using CGI variables to extract the full URL and the hostname from the current URL:</p>
  
  <pre><code>&lt;cfset currentURL = CGI.SERVER_NAME&gt;
  &lt;cfset host = ListFirst(currentURL, ".")&gt;
  </code></pre>
  
  <p>The previous code works as expected.</p>
  
  <p>I would like to also extract the domain. I can't find a CGI variable for that surprisingly, and I have tried the following code but it does not seem to work:</p>
  
  <pre><code>&lt;cfset domain = ListLast(currentURL, "#host#")&gt;
  </code></pre>
  
  <p>But the domain variable is only showing 'om' instead of 'domain.com' when I output it. What am I doing wrong here?</p>