Trace a Redirect Chain
After a site migration, some old links take five redirects, and one loops forever. curl -L only shows the end result. A test site runs on http://127.0.0.1:8098/ (start it with /srv/lab/bin/start-redirects); try /old, /loop-a and /chain0.
Create the executable script /home/student/bin/redirects.sh URL that requests URL and follows redirects one by one, printing for each response <status> <url requested>:
301 http://127.0.0.1:8098/old
302 http://127.0.0.1:8098/new
200 http://127.0.0.1:8098/final?x=1
Location headers may be relative (/new, final) or scheme-relative (//host/path): resolve them against the current URL.0 if the last response is 2xx, 1 if it is another non-redirect status.2, without requesting it, when the next URL was already requested (a loop) or when 10 redirects have already been followed.About this machine
Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.
Teaching or writing about this? Embed this lab on your page
Your machine is ready to start
A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.
No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.