Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

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>
share|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
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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