I know about using CNAME records to redirect example.com to www.example.com, but how would I go about redirecting example.com to sub.example.com and also www.example.com to sub.exaple.com? Do I do so via editing my DNS zone files or a HTTP redirect with my webserver?

Also, what would be the correct terminology to refer to SUB.example.com? Is it hostname, leaf domain?

Update: I'm only interested in hosting a simple static site on a dedicated server using Octopress and Nginx. I don't particularly care about SEO and Google PR etc.

1 Answer 1


The best method is to use HTTP redirect rules for those items if you have access to make those changes. If you are in a hosting plan that doesn't allow you to make that direct modification, then you can use the less elegant but equally valid in some cases of using index.php/index.asp/or whatnot allowed by your server, to parse and redirect server-side. Its an ugly hack but in some cases necessary.


Well there is not real concept of "redirection" in DNS. What you are trying to achieve would be done by tricking it by setting up say SUB.DOMAIN.COM using an "A" record with the address of the webserver. Then setup DOMAIN.COM using "CNAME" pointing to SUB.DOMAIN.COM and then you need to configure your webserver to "redirect" the requests for DOMAIN.COM to SUB.DOMAIN.COM and/or serve the same page for both unless you REALLY want the redirect.

Another solution can be pointing everything to the same server address (so means no messing with the DNS records) and then use .htaccess file with the mod_Rewrite to test what was asked for and then redirect to that resource. Simple as that. So your call how easy or hard you want to make this for yourself. That's why I suggested what I did earlier before the update.

  • See update above. Is it possible to do so using any DNS zone modifications?
    – frosty
    Oct 2, 2013 at 20:44
  • @frosty, see the update. Oct 2, 2013 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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