The referrer is the address of the page from which a visitor reached the current page. The browser sends it in the HTTP header Referer, so the target server learns where the request came from. MDN names analytics, logging and caching optimization as typical uses.
How does it work?
When someone clicks a link, the browser can include the URL of the originating page in the header. Server logs and analytics tools then show which page referred the visit. If someone types an address or opens a bookmark, there is no originating page and therefore no referrer.
The header name is a historic misspelling. The specification spells it Referer with one r, while the concept and the Referrer-Policy header use two.
The header can contain origin, path and query string, but not the fragment or login data. Because URLs can hold sensitive information, RFC 9110 points to privacy risks and to policies that limit when the header is sent. The Referrer-Policy header controls how much is sent. It can be set as an HTTP header, with a meta tag or as an attribute on a single element. Without a setting, browsers use strict-origin-when-cross-origin according to MDN. Within the same origin the full URL is sent. To other origins only the origin is sent, and nothing is sent when the connection drops from HTTPS to HTTP.
Example
Referer: https://www.example.com/guides/
<meta name="referrer" content="origin">
With origin the browser only sends https://www.example.com/. On a single link, rel="noreferrer" switches the header off.
Relevance for SEO
Analytics tools and the Combined Log Format use the referrer to assign visits to sources such as other websites or search engines. Stricter policies reduce how much detail arrives.
Common mistakes
- Mixing the spellings. The request header is
Referer, the policy header isReferrer-Policy. Server rules and log formats need the matching spelling. - Confusing
noreferrerandno-referrer. On a link it isrel="noreferrer"without a hyphen. In the meta tag and the header it isno-referrerwith a hyphen (MDN). - Setting a strict policy without considering the effects. With
no-referrerthe header is omitted entirely, and withsame-originit is missing for requests to other origins. Target pages and their analytics then see no source. - Treating a missing referrer as “direct”. Besides typed addresses and bookmarks, a policy can suppress the header too.
FAQ
What is an HTTP referrer? The header that names the previous page of a request.
Can the referrer be spoofed? Yes. Like the user agent, clients can set it freely, so it is not proof of origin.
Sources
- Referer header – MDN Web Docsdeveloper.mozilla.org
- Referrer-Policy header – MDN Web Docsdeveloper.mozilla.org
- RFC 9110, section 10.1.3 Referer – IETFrfc-editor.org
- Referrer – Seobility Wiki (secondary)seobility.net
Last updated: