I want to create a record in my zone file which, by default goes to my webserver when I type in "mydomain.com" as opposed to "www.mydomain.com" <-- working.

can someone give me some pointers, I know this is probably very easy but the search terms lead google to just spit out useless info.

UPDATED (with zone file)

$ORIGIN mydomain.com.


@   SOA     dns.mydomain.com.     root.mydomain.com. (12 4h 1h 1w 1h)
@   IN  NS  dns.mydomain.com.

dns.mydomain.com.       IN      A       my.ip.add.ress
@               IN      A       my.ip.add.ress
sys                 IN      A       my.ip.add.ress
mail                    IN      A       my.ip.add.ress

                        IN  MX      10      my.ip.add.ress
www.mydomain.com        IN  CNAME   mydomain.com

Thanks very much!

  • 2
    What's the actual question here? You want to remove the WWW part? If so, that's done by a HTTP Redirect (how depends on what web server you're using). DNS has no redirection capability. – Chris S Jan 3 '13 at 14:56
  • no, when I type in the domain directly I get nothing in the browser, just a timeout, but if I use the www.domainname.com I get my webpage as expected, I know you can redirect from the www.xyz.com to the xyz.com with httpd.conf/.htaccess but if I did this I would be redirecting to nothing because the dns is not right somewhere – Alex Jan 3 '13 at 15:12
  • 2
    @Alex: You are missing two . in the last line. www.mydomain.com. and mydomain.com. should end with . as shown in my answer below. – Khaled Jan 3 '13 at 15:13

You need to have a part in your zone definition similar to this:

@                       IN      A       your.ip.addr.ress
www.mydomain.com.       IN      CNAME   mydomain.com.

To summarize, you define the A record for your domain mydomain.com and define a CNAME for it as www.mydomain.com.

  • Thank Khaled, sadly no joy. I've updated the question with the zone file for the domain. I'm running an internal nameserver and it's all working except for removal of the "www". Any thoughts would be greatly appriciated. – Alex Jan 3 '13 at 14:51
  • See Khaled's comment above -- in your updated zone file you declare a cname record: "www.domain.com IN CNAME domain.com" -- If you did that in your real zone file with the real names, you would actually be declaring a CNAME record for www.domain.com.domain.com that pointed to "domain.com.domain.com" because names that are not fully qualified (FQDNs) have the origin appended to them. The "."s at the end of the labels are very significant. A better declaration would be: "www in cname mydomain.com." – Michael McNally Jan 4 '13 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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