Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

If I have the following records in the DNS:

hostname               Record Type         address
benmccormack.com       A                   216.10.244.61
www.benmccormack.com   CNAME               benmccormack.com

What should the user expect to see in a browser's address bar when they type in http://benmccormack.com? how about http://www.benmccormack.com? I was expecting that I would see http://www.benmccormack.com change to http://benmccormack.com in the address bar, but perhaps I misunderstand how a CNAME record is supposed to work.

(Note: I just updated the dns for my site about 15 minutes ago, so perhaps the changes haven't propagated yet.)

share|improve this question
add comment

3 Answers 3

up vote 4 down vote accepted

They should see whatever address they type in, unless you've set up some sort of redirect on the webserver.

Also, it looks like either you didn't update your zone file correctly or it hasn't propogated yet, as the www.benmccormack.com is coming back as an A record:

$ dig www.benmccormack.com

; <<>> DiG 9.6.0-APPLE-P2 <<>> www.benmccormack.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 809
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.benmccormack.com.  	IN	A

;; ANSWER SECTION:
www.benmccormack.com.   3600	IN	A	216.10.244.61
share|improve this answer
add comment

A CNAME is a DNS thing, a URL is a browser thing. Other than using DNS to look up the name in the URL hostname field, the two don't really affect one another.

If you want to do this, here's what I do on Apache 2 configs to redirect from one to the other:

<VirtualHost *:80>
  ServerName www.waywardgypsy.com
  RedirectMatch permanent /(.*) http://waywardgypsy.com/$1
</VirtualHost>
share|improve this answer
    
that makes sense. I'm working with a hosted site's DNS (on IIS, I think. The main site is IIS). –  Ben McCormack Dec 3 '09 at 3:19
add comment

You've setup the DNS correctly. The "www" part of the URL should not be mandatory so both "benmccormack.com" and "www.benmccormack.com" should resolve to the same web server. That is the way it is intended to be.

If you want to redirect all requests to the non-www form, add this to Apache conf. file

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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