#!/bin/bash
# URL to check
url="http://example.com"
# Expected redirect location
expected_redirect="http://example.com/new-location"
# Send a request and extract the actual redirect location
actual_redirect=$(curl -Ls -o /dev/null -w %{url_effective} "$url")
# Compare the actual redirect location with the expected one
if [ "$actual_redirect" = "$expected_redirect" ]; then
echo "Redirect is correct: $actual_redirect"
else
echo "Redirect is incorrect: Expected $expected_redirect, but got $actual_redirect"
fi
Motivation: healthcheck.
PoC