≡ Menu

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:

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

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:

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

Sample outputs:

HTTP/1.1 200 OK
Cache-Control: max-age=5184000
Connection: Keep-Alive
Content-Type: text/html
Date: Sun, 06 Nov 2011 21:53:08 GMT
Expires: Thu, 05 Jan 2012 21:53:08 GMT
Server: nginx
Via: 1.1 mfc1.static.cache.cyberciti.biz:80
X-Cache: HIT 
X-Whom: l3-biz-cyber
X-Galaxy: Andromeda-1

Please note that you need to configure web server OR app server for “debugLB” HTTP referrer in advance.

Share this tutorial on:

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 you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:



{ 3 comments… add one }
  • WAPTRICK October 14, 2013, 8:51 pm

    Thank you so much for this helpful resource. I was seeking this for this solution in php CURL and found the solution here. Thanks

    • DJ March 10, 2015, 8:59 pm

      Not bad. Will this work from Mac?

      • yes March 1, 2016, 1:40 pm

        Yes, it will certainly penetrate through your anus inside and work on your mac.

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: , , , , , , , , , , , , , , , , ,