title: How can I check for domain.com or sub.domain.com?
body: <p>I tried <code>$_SERVER['HTTP_HOST']</code> &amp; <code>$_SERVER['SERVER_NAME']</code>, but they both return <strong>sub.domain.com</strong>, I want it to check if the URL is <em>sub.domain.com</em>, or <em>just domain.com</em>.</p>
  
  <p>Script is run on sub.domain.com and they BOTH return the same data.</p>
  
  <p><code>$_SERVER['HTTP_HOST']</code> returns: sub.domain.com
  <code>$_SERVER['SERVER_NAME']</code> returns: sub.domain.com</p>
  
  <p>I wish to obtain only the domain.com portion of the url. Since the script may run on any subdomain name, I am unsure of how to do so since both of the above variables return the same information. </p>