This curl recipe shows you how to make curl always follow 301, 302, 303, or any other 3XX redirect. By default, curl doesn't follow redirects. To make it follow all redirects, use the -L command line option.

Follow Any Redirect

curl -L http://catonmat.net

This recipe uses the -L argument that forces curl to follow all possible redirects. In this recipe, curl is requesting http://catonmat.net but as this website has moved to https, it sends a 301 redirect response to https://catonmat.net. Curl sees it, follows it, and fetches the https version of the website.

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.