title: PHP: How to get referrer URL?
body: <p>I have a page (<code>index.php</code>) where customers can send me emails. Now I want to see from what website that visitor is coming from.</p>
  <p>How can I get the <code>Referrer URL</code> with PHP? I tried with
  <code>$_SERVER['HTTP_REFERER']</code> but it's empty all the time. What variable do I need to consider?</p>
  <p>Here is what my <code>$_SERVER</code> contains; I put some <code>---- CENSORED ----</code> for privacy concerns, there are actually real values.</p>
  <pre><code>array(31) {
    [&quot;DOCUMENT_ROOT&quot;]=&gt;
    string(33) &quot;/home/anything/public_html/design&quot;
    [&quot;GATEWAY_INTERFACE&quot;]=&gt;
    string(7) &quot;CGI/1.1&quot;
    [&quot;HTTP_ACCEPT&quot;]=&gt;
    string(129) &quot;text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1&quot;
    [&quot;HTTP_ACCEPT_ENCODING&quot;]=&gt;
    string(13) &quot;gzip, deflate&quot;
    [&quot;HTTP_ACCEPT_LANGUAGE&quot;]=&gt;
    string(14) &quot;en-US,en;q=0.9&quot;
    [&quot;HTTP_CACHE_CONTROL&quot;]=&gt;
    string(8) &quot;no-cache&quot;
    [&quot;HTTP_CONNECTION&quot;]=&gt;
    string(10) &quot;Keep-Alive&quot;
    [&quot;HTTP_COOKIE&quot;]=&gt;
    string(189) &quot;__utma=76630272.1468291432.1367655794.1367669576.1367674157.3; __utmb=76630272.1.10.1367674157; __utmc=76630272; __utmz=76630272.1367655794.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)&quot;
    [&quot;HTTP_HOST&quot;]=&gt;
    string(25) &quot; ---- CENSORED ---- &quot;
    [&quot;HTTP_USER_AGENT&quot;]=&gt;
    string(57) &quot;Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.15&quot;
    [&quot;PATH&quot;]=&gt;
    string(13) &quot;/bin:/usr/bin&quot;
    [&quot;QUERY_STRING&quot;]=&gt;
    string(0) &quot;&quot;
    [&quot;REDIRECT_STATUS&quot;]=&gt;
    string(3) &quot;200&quot;
    [&quot;REMOTE_ADDR&quot;]=&gt;
    string(10) &quot;5.15.68.79&quot;
    [&quot;REMOTE_PORT&quot;]=&gt;
    string(5) &quot;57897&quot;
    [&quot;REQUEST_METHOD&quot;]=&gt;
    string(3) &quot;GET&quot;
    [&quot;REQUEST_URI&quot;]=&gt;
    string(12) &quot;/referer.php&quot;
    [&quot;SCRIPT_FILENAME&quot;]=&gt;
    string(45) &quot;/home/anything/public_html/design/referer.php&quot;
    [&quot;SCRIPT_NAME&quot;]=&gt;
    string(12) &quot;/referer.php&quot;
    [&quot;SERVER_ADDR&quot;]=&gt;
    string(13) &quot; ---- CENSORED ---- &quot;
    [&quot;SERVER_ADMIN&quot;]=&gt;
    string(35) &quot; ---- CENSORED ---- &quot;
    [&quot;SERVER_NAME&quot;]=&gt;
    string(25) &quot; ---- CENSORED ---- &quot;
    [&quot;SERVER_PORT&quot;]=&gt;
    string(2) &quot;80&quot;
    [&quot;SERVER_PROTOCOL&quot;]=&gt;
    string(8) &quot;HTTP/1.1&quot;
    [&quot;SERVER_SIGNATURE&quot;]=&gt;
    string(189) &quot;
  Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at ---- CENSORED ---- Port 80
  
  &quot;
    [&quot;SERVER_SOFTWARE&quot;]=&gt;
    string(125) &quot;Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635&quot;
    [&quot;UNIQUE_ID&quot;]=&gt;
    string(24) &quot;UYUNcUPeiDsAABkR2eYAAAAj&quot;
    [&quot;PHP_SELF&quot;]=&gt;
    string(12) &quot;/referer.php&quot;
    [&quot;REQUEST_TIME&quot;]=&gt;
    int(1367674225)
    [&quot;argv&quot;]=&gt;
    array(0) {
    }
    [&quot;argc&quot;]=&gt;
    int(0)
  }
  </code></pre>