tags:

views:

46

answers:

3

As I understand this can be done by either changing the CNAME record in the DNS. Or this can be done using HTTP redirects. I am wondering what is a recommended way of doing this and pros and cons of each approach. What would be friendlier option for search engine like Google?

+1  A: 

The correct method usually stated for URL redirection is to have the server configured to send the 301 Moved Permanently or 307 Moved Temporarily HTTP Header Code.

The Javascript window.location.href method will probably be ignored by search engines, while the <meta> refresh method is usually considered a bad practice.

The Wikipedia page documents each method with a fair amount of detail.

Yi Jiang
Additionally, not only 'meta refresh', but the Refresh header too is considered bad.
Lekensteyn
A: 

You would want to use the .htaccess file to ask the HTTP server to send a 301 response.

Reference

Benny Ng
+1  A: 

Extending Yi Jiang's fine answer, there is also 303 See Other which is subtly different from 301 and 307.

  • 301 roughly says "do not try this URI again, always use the one I'm giving you now".
  • 303 roughly says "you may try this URI again, but use the one I'm giving you for now with GET".
  • 307 roughly says "you may try this URI again, but use the one I'm giving you for now with the same method".

The important thing about 303 is that if the original request was not a GET it is implied that the operation succeeded but further response is to be found elsewhere. Semantically the difference between 301/307 and 303 is that the former are replacements (this replaces that) and the latter is a diversion (this is in addition to that).

annakata
thanks. how is changing the mapping in dns using cname record compare with the above approach?
@saminny - Completely different beast really. HTTP redirs express meaning, a DNS change expresses nothing. HTTP is programatically changeable and flexible, DNS changes are a bit slower and less flexible (afaik). Both are useful under different circumstances, but DNS is much rarer. Caveat: I am not a sys ops guy, my DNS experience only derives from my past conversations with them.
annakata