Shell command to see the HTTP headers
Solution 1:
In order to retrieve only the header, give this a try:
curl -I http://www.example.com/test.php
From the man
page:
-I/--head
(HTTP/FTP/FILE) Fetch the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on a FTP or FILE file, curl displays the file size and last modification time only.
Solution 2:
Use wget for instance
wget -O - -o /dev/null --save-headers www.example.com/test.php
Solution 3:
You can do that with curl:
curl -i 'http://example.com/'
Result:
HTTP/1.0 302 Found
Location: http://www.iana.org/domains/example/
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
(for some reason, IANA decided to redirect example.com, result: no body)
curls manual page about the -i
option:
-i/--include
(HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more...