Skip to content

Instantly share code, notes, and snippets.

@HarryR
Last active February 16, 2017 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HarryR/1cf567db89b82cff66eaab719ffa02e2 to your computer and use it in GitHub Desktop.
Save HarryR/1cf567db89b82cff66eaab719ffa02e2 to your computer and use it in GitHub Desktop.
Check domain for HTTP/HTTPS redirects
#!/usr/bin/env bash
check_domain () {
local DOMAIN=$1
local LOCATION=`curl -vq -o /dev/null http://$DOMAIN/ &> /dev/stdout | grep Location:`
curl -vq -o /dev/null https://$DOMAIN/ &> /dev/null
echo -n "$DOMAIN "
OK=$?
if [[ $OK -eq 0 ]]; then
echo -n "HAS-HTTPS"
else
echo -n "NO-HTTPS"
fi
echo $LOCATION | grep "https://$DOMAIN/" &> /dev/null
OK=$?
if [[ $OK -eq 0 ]]; then
echo -n " HTTPS-REDIRECT "
fi
echo " $LOCATION"
}
for DOMAIN in $*
do
check_domain $DOMAIN
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment