Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A oneliner for testing redirects
#!/bin/bash
# The following line defines a bash function and is designed to be copy-pasta-ed into your terminal and used as shown on the last line of this file. I'm only putting it in a script to get it on gist
redir_test(){ curl -svLo /tmp/redir_test.out "$@" 2>&1 | grep -E '^(> Host|> GET|< HTTP|< location|[<>]\s*$)'; }
# BONUS: One super-useful use of this is to test your readiness to respond to future DNS changes. That can be done like so:
# redir_test -H 'Host: www.example.com' https://192.168.0.101/
# This assumes that your server at 192.168.0.101 is set up to serve www.example.com and this simulates what `curl https://www.example.com/` would do if DNS returned 192.168.0.101 when doing a lookup on www.example.com
redir_test "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.