How to Use curl to Print the Location Header in a Response?

18 Replies, 791 Views

Nice one! I’ve been using a similar approach for curl print location header, but I like how you’ve simplified it. One thing I’d add is using `-L` to follow the redirects automatically. Sometimes the location header isn’t in the first response, so this helps.

For example:
```bash
curl -s -o /dev/null -w "%{redirect_url}" -L http://example.com
```

Also, if you’re dealing with multiple redirects, tools like `httpie` or Postman can visualize the chain better.

Messages In This Thread



Users browsing this thread: 1 Guest(s)