Using -l
or --location
one can follow redirects using cURL. Let’s understand it with a real-world example.
curl -L http://www.scrapingdog.com
- Initial URL was
http://www.scrapingdog.com
. - Scrapingdog issues a
301
redirect with theLocation
header pointing tohttps://www.scrapingdog.com
. - Final URL is
https://www.scrapingdog.com
.
If you need HTTP headers in the output then you can use -i
option of cURL.
curl -L -i http://www.scrapingdog.com