Difference between Redirect and CNAME

I am no more confused by the differences between name alias with CName record and Redirect settings provided by web hostings.

CName

Setting

Set a CName DNS record to add alias google.charliezhu.com to www.google.com

ip of google.charliezhu.com

E:\Documents and Settings\Charliezhu>ping google.charliezhu.com
Pinging www.l.google.com [64.233.189.104] with 32 bytes of data:

ip of google.com

E:\Documents and Settings\Charliezhu>ping google.com
Pinging www.l.google.com [64.233.189.104] with 32 bytes of data:

The HTTP headers

GET / HTTP/1.1
Host: google.charliezhu.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

HTTP/1.x 200 OK
Cache-Control: private
Content-Type: text/html
Set-Cookie: PREF=ID=18f0202fad0f0342:NW=1:TM=1166005857:LM=1166005857:S=XPXvoWJWL4FJ2qOF; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
Content-Encoding: gzip
Server: GWS/2.1
Content-Length: 1430
Date: Wed, 13 Dec 2006 10:30:57 GMT

Packets captured

The DNS server handles name resolve for the alias and answers proper CNAME class DNS responses.

dns.cname

Browser address bar

Browser never knows the address is an alias.

dns.cname.address.bar

Redirect

Setting

Add a sub-domain google-re.charliezhu.com as Redirect to http://www.google.com.

The HTTP Headers

The HTTP server echoes a response that tell the browser to redirect to another URL. That means the setting such as “redirect”, “auto forward” and so on are all handled by the Web servers but the DNS servers. They response to browser and expect the browser to make another request to the target host. That is totally ANOTHER web page request process as every time we type address in the address bar then go.

Some hosting as domainbank.com provided a URL forwarding service. It is implemented by HTTP server too and just responses a web page with frame contents the target URL you specified.

GET / HTTP/1.1
Host: google-re.charliezhu.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
… …

HTTP/1.x 301 Moved Permanently
Date: Wed, 13 Dec 2006 11:12:57 GMT
Server: Apache/2.0.54 (Unix) PHP/4.4.2 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2 SVN/1.1.4
Location: http://www.google.com/
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 190
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1
———————————————————-

GET / HTTP/1.1
Host: www.google.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
… …

HTTP/1.x 200 OK
Cache-Control: private
Content-Type: text/html
Content-Encoding: gzip
Server: GWS/2.1
Content-Length: 1977
Date: Wed, 13 Dec 2006 11:12:56 GMT

related post: 域名的基本概念

No comments yet. Be the first.

Leave a reply

Random posts

  • 感冒了
  • 解决在firefox中word-wrap, word-break的问题
  • Yahoo原来这么狠
  • 富兰克林的13项美德
  • 抽象归纳数据结构,重用算法