A
A
Alexander Krysko2018-04-27 12:00:27
bash
Alexander Krysko, 2018-04-27 12:00:27

Where does the domain redirect?

Good day. Using the command,
curl -Is domain.com | head -n 1
I can find out if the domain is redirecting somewhere or not (if 200 is ok, if 301 is a redirect).
But how do I output to the terminal it redirects to using BASH?
Sorry for the crooked question.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
x1shn1k, 2018-04-27
@Little_man

In one script I use the following construction:

curl --connect-timeout 10 -I -s -o /dev/null -w "%{http_code} %{url_effective}\n==> %{redirect_url}\n\n" domain.com

M
mureevms, 2018-04-27
@mureevms

wget follows the redirects by itself and shows this:

wget domain.com 
--2018-04-27 16:15:20--  http://domain.com/
Resolving domain.com (domain.com)... 13.228.112.135
Connecting to domain.com (domain.com)|13.228.112.135|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://domain.com/ [following]
--2018-04-27 16:15:21--  https://domain.com/
Connecting to domain.com (domain.com)|13.228.112.135|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www.domain.com/ [following]
--2018-04-27 16:15:23--  https://www.domain.com/
Resolving www.domain.com (www.domain.com)... 13.228.112.135
Connecting to www.domain.com (www.domain.com)|13.228.112.135|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question