Skip to content
curl

Follow Redirects

Chase 3xx responses automatically.

#redirect#3xx

Code

curl
# Follow redirects
curl -L https://example.com/redirect

# Limit the number of redirects
curl -L --max-redirs 5 https://example.com

# Show the redirect chain
curl -L -v https://example.com 2>&1 | grep "Location:"

# Preserve POST method on 301/302 (off by default)
curl -L --post301 --post302 -d "x=1" https://example.com

# Stop if a redirect loop is detected
curl -L --max-redirs 3 https://example.com