How to follow redirects with command line cURL tool

September 27, 2022 No comments curl follow-redirects command

1. Using the -L or --location flag

According to manual: The -L option will force curl to retry the request on the new location if the server detects that the requested page has moved (marked with a Location: header and a 3XX response code).

To follow redirects use the command:

curl -L


curl --location

2. Limit the number of redirects --max-redirs

You are also able to limit the number of redirects using --max-redirs parameter. By default, the limit is set to 50 redirects. To make unlimited redirections use -1 value.

Example command:

curl --max-redirs 5 -L
{{ message }}

{{ 'Comments are closed.' | trans }}