How to list all URL's in Redirect chain

This simple utility is extremely useful in detecting bad redirects and loops, specially in big websites. You can also include it in scripts.

wget http://gmail.com 2>&1 | grep Location:

The response, in this case, is:

Location: https://www.google.com/gmail/ [following]
Location: https://mail.google.com/mail/ [following]
Location: https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1# [following]