I thought I would be able to retrieve the same information by using something like
<?php
$referrer = $_SERVER['HTTP_REFERRER'];
echo "referrer is: $referrer \n";
?>
but alas, no referrer gets output... other elements of $_SERVER array can get output, such as HTTP_USER_AGENT, but not the HTTP_REFERRER.
So to see which elements were populated by default, I saved the following script as show_elements.php
<?php
print_r($_SERVER);
?>
and when I point my browser to this file, it yields:
Array ( [DOCUMENT_ROOT] => /Library/WebServer/Documents/my.example.com [HTTP_ACCEPT] => text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8 ,image/png,*/*;q=0.5 [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 [HTTP_ACCEPT_ENCODING] => gzip,deflate [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5 [HTTP_CONNECTION] => keep-alive [HTTP_HOST] => my.example.com [HTTP_KEEP_ALIVE] => 300 [HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11 [PATH] => /bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServices [REMOTE_ADDR] => ##.##.##.###(my.remote.ip) [REMOTE_PORT] => 54136 [SCRIPT_FILENAME] => /Library/WebServer/Documents/my.example.com/show_elements.php [SCRIPT_URI] =>
http://my.example.com/show_elements.php [SCRIPT_URL] => /show_elements.php [SERVER_ADDR] => 192.168.2.224 [SERVER_ADMIN] => admin@example.com [SERVER_NAME] => my.example.com [SERVER_PORT] => 80 [SERVER_SIGNATURE] =>
Apache/1.3.33 Server at my.example.com Port 80
[SERVER_SOFTWARE] => Apache/1.3.33 (Darwin) mod_jk/1.2.6 DAV/1.0.3 mod_ssl/2.8.24 OpenSSL/0.9.7i PHP/4.4.1 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /show_elements.php [SCRIPT_NAME] => /show_elements.php [PATH_TRANSLATED] => /Library/WebServer/Documents/my.example.com/show_elements.php [PHP_SELF] => /show_elements.php [argv] => Array ( ) [argc] => 0 )
The php manual says that the entries of the $_SERVER array are set by the web server, so, the question, in my mind, is how to get Apache to populate the HTTP_REFERRER element of the $_SERVER array?
I would find this useful for tracking effectiveness of link exchanges, paid advertising, and much more, and would love it if this topic gets resolved...
Dual G4 colocated xserves Mac OS X (10.4.7)