This curl recipe shows you how to add a referrer to a curl request. Web servers often check the referrer before allowing the request, so you better know how to set it. To set a referrer use the -e 'https://url.com' argument.

Add a Referrer

curl -e 'https://google.com?q=cats' http://catonmat.net

This recipe uses the -e argument sets the HTTP referrer to https://google.com?q=cats and makes a GET request to https://catonmat.net. When the owner of catonmat.net will look in his access.log files, he'll think that someone came from Google while searching for cats, but in reality, we'll have bamboozled the owner catonmat.net.

Send an Empty Referrer

curl -e '' http://catonmat.net

This recipe also uses the -e option to set the referer but it leaves the argument empty '' (set to nothing). This clears the value part of Referer: HTTP header and curl send an empty HTTP referer.

Send a Referer via the -H argument

curl -H 'Referer: https://digg.com' http://catonmat.net

This recipe is for pros only. Normally, you'd send the referrer via -e (as illustrated in the previous recipes) but you can also send it via the -H 'Referer: URL' argument that sets the full HTTP header. In this recipe, the HTTP header is set to Referer: https://digg.com so the web server at catonmat.net will think the request came from this address.

Created by Browserling

These curl recipes were written down by me and my team at Browserling. We use recipes like this every day to get things done and improve our product. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!

Secret message: If you love my curl recipe, then I love you, too! Use coupon code CURLLING to get a discount at my company.