Linux / Unix curl: Pass HTTP Referer

How do I pass the referrer (HTTP referrer)as an HTTP header field using curl command under Linux OR Unix operating systems? The curl client / command can send the “Referer Page” information to the Web (HTTPD) server. By default, when visiting a webpage using any HTTP client, the referrer or referring page is the URL of the previous webpage from which a link was followed. This can be changed using the following syntax:

Adblock detected 😱

My website is made possible by displaying online advertisements to my visitors. I get it! Ads are annoying but they help keep this website running. It is hard to keep the site running and producing new content when so many people block ads. Please consider donating money to the nixCraft via PayPal/Bitcoin, or become a supporter using Patreon.

curl --referer http://example.com/bot.html http://www.cyberciti.biz/

curl --referer http://example.com/bot.html http://www.cyberciti.biz/

This can be used for referrer spoofing. In this example change referrer information to “fooBar” to prevent a web page from gathering accurate data on the identity of the user’s previously visited web page:

curl --referer fooBar www.cyberciti.biz

curl --referer fooBar www.cyberciti.biz

The HTTP referer can be used for testing and debugging complex setups. In this example, if you pass “debugLB” as HTTP referrer, you will see ‘X-Cache’ and ‘Via’ debug headers:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Your support makes a big difference:

I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft takes a lot of my time and hard work to produce. If everyone who reads nixCraft, who likes it, helps fund it, my future would be more secure. You can donate as little as $1 to support nixCraft: