The role of Referer in the HTTP request header


In the HTTP request, Referer is a part of the header. When the browser sends a request to the web server, it will generally bring the Referer to tell the server which page the webpage is linked from, so that the server can obtain some information for processing.

For example, if is a in , then click this, and its header information will contain: Referer=


1. Anti-leech

Only my own website is allowed to access my own picture server. If the domain name is, then the picture server gets Referer every time to judge whether the domain name is right If it is, continue to visit, if not, block it.

After sending this http request to the server, if the server requires a certain address or several addresses to access, and the referer you sent does not meet his requirements, it will intercept or jump to the address he requested, and then access through this address.

2. Prevent malicious requests

For certain high-risk file types, you can use Referer so that this type of file can only come from the website I specify.

Empty Referer

Sometimes, the content of Referer is empty. According to the definition of Referer, its function is to indicate where a request is linked from. If a request is not triggered by a link, then naturally there is no need to specify the link source of the request.

For example, if you directly enter the URL address of a resource in the address bar of the browser, then this request will not include the Referer field, because this is a "generated out of thin air" HTTP request, not linked from one place.

The cases where the Referer content is empty include:

  • Enter the URL directly in the browser
  • Hyperlink icon on Windows desktop
  • In-browser bookmarks
  • Links in Third Party Software Content

Guess you like