Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does refer(r)er work technically?

I don't understand: how are webserver and trackers like Google Analytics able to track referrals?

Is it part of HTTP?

Is it some (un)specified behavior of the browsers?

Apparently every time you click on a link on a web page, the original web page is passed along the request.

What is the exact mechanism behind that? Is it specified by some spec?

I've read a few docs and I've played with my own Tomcat server and my own Google Analytics account, but I don't understand how the "magic" happens.

Bonus (totally related) question: if, on my own website (served by Tomcat), I put a link to another site, does the other site see my website as the "referrer" without me doing anything special in Tomcat?

like image 556
NoozNooz42 Avatar asked Jun 18 '10 00:06

NoozNooz42


People also ask

How does referrer header work?

The Referer header allows a server to identify a page where people are visiting it from. This data can be used for analytics, logging, optimized caching, and more. When you follow a link, the Referer contains the address of the page that owns the link.

Can you fake the referrer?

Several software tools exist to facilitate referer spoofing in web browsers. Some are extensions to popular browsers such as Mozilla Firefox or Internet Explorer, which may provide facilities to customise and manage referrer URLs for each website the user visits.

What is referrer example?

In more simple terms, the referer is the URL from which came a request received by a server. A good example is if you click a link on the page site.com/page to go to another-site.com/link, the HTTP Referer received by another-site.com/link will have the value site.com/page.

Is the referer header always sent?

Some web browsers give their users the option to turn off referrer fields in the request header. Most web browsers do not send the referrer field when they are instructed to redirect using the "Refresh" field. This does not include some versions of Opera and many mobile web browsers.

What is $_ server [' Http_referer ']?

$_SERVER['HTTP_REFERER'] Returns the complete URL of the current page (not reliable because not all user-agents support it) $_SERVER['HTTPS'] Is the script queried through a secure HTTP protocol.


1 Answers

Referer (misspelled in the spec) is an HTTP header. It's a standard header that all major HTTP clients support (though some proxy servers and firewalls can be configured to strip it or mangle it). When you click on a link, your browser sends an HTTP request that contains the page being requested and the page on which the link was found, among other things.

Since this is a client/request header, the server is irrelevant, and yes, clicking a link on a page hosted on your own server would result in that page's URL being sent to the other site's server, though your server may not necessarily be accessible from that other site, depending on your network configuration.

like image 134
Chris Avatar answered Oct 13 '22 04:10

Chris