201

I know it's possible to get an empty HTTP_REFERER. Under what circumstances does this happen? If I get an empty one, does it always mean that the user changed it? Is getting an empty one the same as getting a null one? and under what circumstances do I get that too?

1

5 Answers 5

334

It will/may be empty or partial when the enduser

  • entered the site URL in browser address bar itself.
  • visited the site by a browser-maintained bookmark.
  • visited the site as first page in a new window/tab/session, in some browsers.
  • clicked a link on a page having restrictive <meta name="referrer"> tag.
  • clicked a link on a page having restrictive Referrer-Policy header.
  • clicked a link having rel="noreferrer".
  • clicked a link in an external application (i.e. not a webbrowser, e.g. Flash).
  • switched from a https URL to a http URL.
  • has security software installed (antivirus/firewall/etc) which strips the referrer from all requests.
  • is behind a proxy which strips the referrer from all requests.
  • visited the site programmatically (like, curl) without setting the referrer header (bots!).
4
  • in Safari (12.0.2), cmd + click on link or left click and open in new tab, http_referer is empty!
    – GrandFelix
    Feb 26, 2019 at 9:22
  • is the only truly effective way to track organic vs search traffic by using canonical links with parameters for search engines?
    – oldboy
    Jul 25, 2019 at 8:26
  • 1
    Wouldn't a page refresh (F5) also show a blank referrer? Or am I mistaken?
    – AaronLS
    Feb 18, 2020 at 19:54
  • based on my experience, and what i read on the internet, the http_referer header is empty in internet explorer
    – shayuna
    Oct 17, 2021 at 8:35
37

HTTP_REFERER - sent by the browser, stating the last page the browser viewed!

If you trusting [HTTP_REFERER] for any reason that is important, you should not, since it can be faked easily:

  1. Some browsers limit access to not allow HTTP_REFERER to be passed
  2. Type a address in the address bar will not pass the HTTP_REFERER
  3. open a new browser window will not pass the HTTP_REFERER, because HTTP_REFERER = NULL
  4. has some browser addon that blocks it for privacy reasons. Some firewalls and AVs do to.

Try this firefox extension, you'll be able to set any headers you want:

@Master of Celebration:

Firefox:

extensions: refspoof, refontrol, modify headers, no-referer

Completely disable: the option is available in about:config under "network.http.sendRefererHeader" and you want to set this to 0 to disable referer passing.

Google chrome / Chromium:

extensions: noref, spoofy, external noreferrer

Completely disable: Chnage ~/.config/google-chrome/Default/Preferences or ~/.config/chromium/Default/Preferences and set this:

{
   ...
   "enable_referrers": false,
   ...
}

Or simply add --no-referrers to shortcut or in cli:

google-chrome --no-referrers

Opera:

Completely disable: Settings > Preferences > Advanced > Network, and uncheck "Send referrer information"

Spoofing web service:

http://referer.us/

Standalone filtering proxy (spoof any header):

Privoxy

Spoofing http_referer when using wget

‘--referer=url’

Spoofing http_referer when using curl

-e, --referer

Spoofing http_referer wth telnet

telnet www.yoursite.com 80 (press return)
GET /index.html HTTP/1.0 (press return)
Referer: http://www.hah-hah.com (press return)
(press return again)
5
  • Tamper Data is another Firefox extension that's worth a look if you want to play with changing referrer values. Jul 30, 2011 at 2:32
  • I was trying really hard to remember it's name. but my memory betrayed me. Thanks:)
    – ThatGuy
    Jul 30, 2011 at 2:35
  • @nix Some browsers limit access to not allow HTTP_REFERER to be passed Could you please name an example for such browser and/or extension? May 15, 2012 at 10:49
  • @MasterofCelebration added ways to spoof http_referer into my answer.
    – ThatGuy
    May 18, 2012 at 18:54
  • Do not use referer.us to spoof / hide your referrer! It does not work and leaks your information. The only working service right now is this free hide referrer service. Mar 30, 2017 at 2:44
11

It will also be empty if the new Referrer Policy standard draft is used to prevent that the referer header is sent to the request origin. Example:

<meta name="referrer" content="none">

Although Chrome and Firefox have already implemented a draft version of the Referrer Policy, you should be careful with it because for example Chrome expects no-referrer instead of none (and I have seen also never somewhere).

1
9

BalusC's list is solid. One additional way this field frequently appears empty is when the user is behind a proxy server. This is similar to being behind a firewall but is slightly different so I wanted to mention it for the sake of completeness.

0

I have found the browser referer implementation to be really inconsistent.

For example, an anchor element with the "download" attribute works as expected in Safari and sends the referer, but in Chrome the referer will be empty or "-" in the web server logs.

<a href="http://foo.com/foo" download="bar">click to download</a>

Is broken in Chrome - no referer sent.

Not the answer you're looking for? Browse other questions tagged or ask your own question.