The website I built my girlfriend is not resolving on her Mac when she types www in before the domain name. Is it her browser or do I need to set up a www redirect somewhere?

link|improve this question
Yes you do - this question would be better answered at serverfault.com – Andrew Hare Jun 25 '09 at 4:28
Does it work on your machine? If yes, what browser is she using? This has nothing to do with the mac. – rpflo Jun 25 '09 at 4:32
4  
I know this is a nitpick, but example.com/net/org were reserved especially for examples, use them! :P – R. Pate Jun 25 '09 at 4:34
1  
Wow! Serverfault.com... It is like a stackoverflow clone for server stuff. What are some other stackoverflow clones out there? – Bryan Jun 25 '09 at 4:47
it isn't a "clone"... its a "sister" site. its run by the same group... just has a different focus. so far, there are only 2... – nader Jun 25 '09 at 5:00
show 3 more comments
feedback

4 Answers

up vote 14 down vote accepted

I usually set the DNS records like this:

@  IN A  123.123.123.123
www  IN A  123.123.123.123

You could, of course, use a CNAME for the www but I prefer to use A records if not necessary. Also you may (or may not) prefer to use an Alias instead of a redirect.

You set it up in Apache like this:

<VirtualHost 123.123.123.123>
    ServerName example.com
    ServerAlias www.example.com
    ...
</VirtualHost>
link|improve this answer
3  
Precise and correct. – pauska Jun 25 '09 at 8:16
Quite right! Additionally, I always add that ServerName/ServerAlias, respectively with and without the www. precisely for this reason. Many sites nowadays (look at your location bar right now) are opting to drop the www. – msanford Jul 15 '09 at 0:01
I mean, respectively without and with. – msanford Jul 15 '09 at 0:02
feedback

On your DNS management area for your domain you need to add a CNAME record, this basically means the www record will point towards the IP for yourdomain.com:

yourdomain.com  		300  	IN A 		123.123.123.123
www.yourdomain.com  	300 	IN CNAME 	yourdomain.com

Most DNS control panels should give you this ability.

link|improve this answer
feedback

If you only have an A record for example.com, people who query www.example.com will not get a valid response that points them to your server. Same goes for the other way around.

I have seen people set their example.com as an A record and then have a CNAME for www.example.com pointing to example.com. But as using CNAMEs is not encouraged (so I hear, I am not a DNS guy), having two A records for both example.com and www.example.com pointing to the same IP is fine too, I guess.

In short, yes, you need to setup a DNS record for www.example.com as well as for example.com. A redirect will not work, since it is not possible to successfully resolve both hostnames in DNS.

link|improve this answer
2  
This is because of the Google 'juice' is then split. You want to pick one or the other but not both. The one that is not picked should issue a 302 redirect to the correct name. – Jauder Ho Jun 25 '09 at 8:01
1  
@Jauder Ho - You should issue a 301 redirect, not a 302 – John Rasch Nov 19 '09 at 21:03
feedback

Just add an '@' A record and point it to your server's IP address.

link|improve this answer
1  
Adding A record does'nt solve, They are already getting domain.com which is A record , They are asking why www.domain.com is not resolving. For that they have to add an CNAME record that may solve the problem. as Swanny says. – Caterpillar Jun 25 '09 at 10:04
feedback

Your Answer

 
or
required, but never shown

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