
A simple curl command can fetch HTTP headers from a website. Here’s how it works!
The command is:
$ curl -I domain.com
Example:
stmiller@brahms:~$ curl -I http://scottlinux.com HTTP/1.1 200 OK Date: Sat, 24 Sep 2011 02:53:17 GMT Server: Apache Strict-Transport-Security: max-age=43200; includeSubDomains Set-Cookie: bb2_screener_=1316832797+; path=/ X-Pingback: http://scottlinux.com/xmlrpc.php Set-Cookie: PHPSESSID=erh3jr41d1idkaifote48urph4; path=/ X-Hello: Hello There Vary: Accept-Encoding Content-Type: text/html; charset=UTF-8
slashdot.org will give either an x-bender or x-fry header.
stmiller@brahms:~$ curl -I slashdot.org HTTP/1.1 200 OK Server: Apache/1.3.42 (Unix) mod_perl/1.31 SLASH_LOG_DATA: shtml X-Powered-By: Slash 2.00500120110922.02 X-Fry: It's a widely-believed fact! X-XRDS-Location: http://slashdot.org/slashdot.xrds Cache-Control: no-cache Pragma: no-cache Content-Type: text/html; charset=utf-8 Content-Length: 91444 Date: Sat, 24 Sep 2011 02:54:00 GMT X-Varnish: 120240911 120240846 Age: 6 Connection: keep-alive
(Is slashdot really running on apache ver 1.3?!)
Add your own HTTP Header
First, enable Apache mod_headers:
$ sudo a2enmod headers
Next add your own custom header by adding the following to your virtualhost config file
Header set X-Cool "Yeah!"
Example:
Header set X-Cool "Yeah!" < VirtualHost *:80 > DocumentRoot /var/www < Directory / > ...
Cool!