There is a website when you visit certain links it redirects you to another site.

Is there any way I can find out what HTTP code is returned before they redirect you?

link|improve this question
feedback

2 Answers

up vote 3 down vote accepted

Sure, try curl:

$ curl -k https://www.gmail.com/
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
link|improve this answer
1  
That sort of worked. The link I tested showed just Object Moved, then the link to the new location. I tried the same with wget and it showed 302 Found, then after following the link it showed 302 Moved Temporarily. Thanks for pointing my in the right direction. – Shane Grant Oct 15 '11 at 2:18
feedback

curl, wget, ... and other command line web browsers may not be available in all OS, just use telnet instead:

$ telnet localhost 81
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /one/two?path=x&y=z HTTP/1.0
<enter>
<enter>
HTTP/1.1 301 Moved Permanently
Server: nginx/1.0.5
Date: Sat, 15 Oct 2011 02:38:59 GMT
Content-Type: text/html
Content-Length: 184
Location: http://127.0.0.1:81/one/two/x?y=z
Connection: close

You can also pass the Host header:

telnet www.ganglia.gentoo 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.0
Host: www.ganglia.gentoo
<enter>
<enter>
HTTP/1.1 301 Moved Permanently
Date: Sat, 15 Oct 2011 02:45:41 GMT
Server: Apache
Location: http://nagios.gentoo/
Content-Length: 297
Connection: close
Content-Type: text/html; charset=iso-8859-1
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.