Referer
Description
The Referer request header is an HTTP header field used to indicate the URL of the previous webpage from which a request was made. It helps servers and analytics tools understand the source of traffic and can be used for security, logging, and tracking purposes.
The Referer header is commonly included in requests when a user navigates from one webpage to another by clicking a link, submitting a form, or making resource requests (such as images, stylesheets, or scripts). It allows the destination server to see where the request originated from.
However, due to privacy concerns, browsers may limit the information shared in the Referer header or omit it altogether in certain scenarios, such as when navigating from an HTTPS site to an HTTP site.
Syntax
The Referer header follows this syntax:
Referer: <URL>
For example:
Referer: https://example.com/page1.html
When a user clicks a link on page1.html to navigate to another page, the browser includes this header in the request.
Examples
Basic Usage in HTTP Requests
When a user clicks a link from example.com to another-site.com, the request may include the following header:
GET /destination HTTP/1.1
Host: another-site.com
Referer: https://example.com/source-page.html
This allows another-site.com to see where the request originated.
Summary
The Referer request header provides useful information about the origin of web traffic, helping with analytics, security, and debugging. However, privacy considerations and browser restrictions may affect how much information is shared. Modern security practices, such as using the Referrer-Policy header, allow websites to control how the Referer header is handled and shared.