title: Retrieve salesforce instance URL instead of visualforce instance
body: <p>From a visualforce page, I need to retrieve our organization's salesforce instance's URL, and not the visual force URL.</p>
  
  <p>For example I need <code>https://cs1.salesforce.com</code> instead of <code>https://c.cs1.visual.force.com</code></p>
  
  <p>Here's what I've tried so far and the outcome I got:</p>
  
  <p><strong>Accessed the Site global variable from the VF Page:</strong></p>
  
  <p><code>&lt;apex:outputText value="{!$Site.Domain}" /&gt;</code> returns <code>null</code></p>
  
  <p><em>Sidenote: Everything in <code>$Site.xxx</code> seems to return <code>null</code>.</em></p>
  
  <p><strong>From the Apex controller:</strong></p>
  
  <blockquote>
  <pre><code>public String getSfInstance()
  {
    return ApexPages.currentPage().getHeaders().get('Host');
  }
  </code></pre>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
  <pre><code>public String getSfInstance()
  {
    return URL.getSalesforceBaseUrl().toExternalForm();
  }
  </code></pre>
  </blockquote>
  
  <p>returns <code>c.cs1.visual.force.com</code> and <code>https://c.cs1.visual.force.com</code>, respectively.</p>
  
  <p>Question: How do I retrieve what I want: <code>https://cs1.salesforce.com</code>?</p>