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.


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 3 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • WAPTRICK Oct 14, 2013 @ 20:51

    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 Mar 10, 2015 @ 20:59

      Not bad. Will this work from Mac?

      • yes Mar 1, 2016 @ 13:40

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

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum