Forum Moderators: phranque

Message Too Old, No Replies

www and non-www : cname redirection

How to actually set up the cname record

         

LDen1

6:55 pm on Sep 18, 2007 (gmt 0)

10+ Year Member



I know this is not a new subject, but I am new to all this and need a bit of advice about how to actually set up the cname record to make sure that mysite.com is redirected to www.mysite.com to avoid duplicate content penalties from Google.

I have read all other threads on this but unfortunately I need still more explanation.

At my host's DNS settings page, where I find the a records, I am given the option of adding a new a record, cname record or txt record. There are two entry fields either side of a drop down menu which offers the choice of a, cname or txt. These are 'name' and 'content'.

I phoned my website helpdesk and they told me to put:

@ CNAME www.mysite.com.

(i.e. @ in the 'name' field, www.mysite.com. in the 'content' field)

I tried this but it didn't work, I could still go to mysite.com and wasn't redirected to www.mysite.com (unless it takes a certain amount of time before it will take effect)

I realise that this is probably very basic stuff, but I am completely new to websites really and if anyone can help I would be very grateful.

Thanks

jtara

2:59 am on Sep 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You cannot CNAME your base domain name. You must use an A record.

While they may allow you to add that record, it's nonsensical to do so, and resolvers will not be able to do anything useful with it.

You have to do it the other way around - use a CNAME record for "www" to point it to the base name. Use an A record for the base name.

But I find it easier (and it's ever so slightly faster for users) to simply use an A record for both the base name and www.

BTW, how you specify the base name varies between different DNS providers. Some use "@". Mine uses the full domain name, followed by a period. e.g. "example.com." I'm sure others have different ways...

Note that this has no bearing on which variation is used in your "canonical" URL. That's determined by your server redirects. You can set-up your server to either forward www to non-www or non-www to www, as you wish. The DNS setup is the same either way.

LDen1

9:20 am on Sep 19, 2007 (gmt 0)

10+ Year Member



Thank you, that all makes sense now. I hadn't realised that the @ in the A record refered to the base name. I do have an A record for both the www and the base name.

I've set up the web forwarding (I assume this is the same as a server redirect) and it all works prefectly.

Thanks again

jtara

2:23 pm on Sep 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've set up the web forwarding (I assume this is the same as a server redirect) and it all works prefectly.

"Web forwarding" is a service provided by some DNS providers. It is NOT a DNS function at all, but a website that is maintained by the DNS provider which does nothing but redirect.

I think it's odd that you had to fiddle with CNAME or A records at all. This is usually all done for you when you set-up "web forwarding".

Good time to point-out that every DNS provider (and every registrar) has a different user interface - some slightly different from others, some radically different.

Often, their UI hides (to the ultimate detriment of webmasters, I think) the underlying implementation in ways that are sometimes surprising. This is one example. I think most webmasters think that there really is such a thing as "DNS forwarding". There isn't.

Keep that in mind when posting here. Most "how do I..." questions really can't be answered, except in a generic way, and you will need to do some poking to figure out the step-by-step details.

LDen1

3:18 pm on Sep 19, 2007 (gmt 0)

10+ Year Member



I was trying to fiddle with the CNAME / A records after reading this [webmasterworld.com...]

After having set up the 'web-forwarding' today I thought it was working i.e. taking me to www.mysite.com when I typed mysite.com into my web browser. However half an hour later seemed to have stopped working - leading me to question whether it had really been working in the first place or if I had just imagined it.

Would this on/off change be due to propagation or is this not something that would be affected by that. I did have to change the IP addresses in my A records back to their usual settings as the 'web-forwarding' returned them to their defaults)?

Also, I'm afraid I'm still a little unclear, do you think this 'web-forwarding' service I'm trying to use is the best way to achieve my aim?

jtara

5:00 pm on Sep 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also, I'm afraid I'm still a little unclear, do you think this 'web-forwarding' service I'm trying to use is the best way to achieve my aim?

No, I don't.

The best way to do redirection is on your own web server. Then you are in complete control. However, you can't do this with some low-cost and most if not all free hosts. Your host has to support name-based virtual servers.

See the Apache forum here for information on how to set-up redirection on your own server. (Not using Apache? You'll have to do some digging.)

You point the A records for both www and your basename at the same address - your web server. (Or an A record for the basename, and a CNAME for www.)

Something I said earlier may have been confusing and incorrect, though. In your current setup, you would NEVER want to use a CNAME! And I gave you some bum advice on where to point the A records.

Assuming you want "www" to be your canonical name (most common - but I prefer the opposite...), "www" should have an A record that points to your web server. The basename should have an A record that points to your DNS provider's redirection server.

Again, I'm not sure what your DNS provider does as a "side effect" when you set-up redirection. In most cases, they alter the A record for you. Best to set it up and then take a look and see what you've got. It's useful to know how to use nslookup or similar software. If you aren't using Linux on your desktop, there are web-based versions available.

LDen1

11:27 pm on Sep 19, 2007 (gmt 0)

10+ Year Member



I am clearly out of my depth here as most of this goes over my head. I just have one very small very simple website and all I want to do is not be penalised by Google for duplicate content or for anything else.

Can I get this straight, for what I am trying to do what you seem to be saying is:

1. It is not possible or not a good idea to change my basename settings from (what it currently is) - an A record pointing to an IP address to a CNAME pointing to www.example.com/.

i.e. from @ A **.**.***.** to @ CNAME www.example.com

(NB. There is currently also an A record for www pointing to the same IP address)

2. Web forwarding and server redirects are not the same.

3. For my purposes web forwarding is not a good idea.

4. I may not be able to set up a server redirect with a low cost hosting package (which is what I currently have and which, with the exception of this case, fulfills my meagre needs perfectly)

And I guess that

5. If I did upgrade my hosting packagem, I would probably be offered many more options but probably still wouldn't know what to do.

Do you think this is an accurate summary?

[edited by: tedster at 4:12 am (utc) on Sep. 20, 2007]
[edit reason] make specifics generic [/edit]

LDen1

11:53 pm on Sep 19, 2007 (gmt 0)

10+ Year Member



Now I've done something really stupid.

I read elsewhere that I can set up thee redirect using a 301 redirect. So I followed instructions and added

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ [domain.com...] [r=301,nc]

as an .htaccess file. It promptly disappeared from the screen of my ftp client and now I can't access the site at all I just get a 500 Internal Error message.

A little bit of knowledge is a dangerous thing.

Please help.

LDen1

12:06 am on Sep 20, 2007 (gmt 0)

10+ Year Member



Oh and it seemed to chage it's name to .htaccess.rft just before it disappeared.

LDen1

6:17 am on Sep 20, 2007 (gmt 0)

10+ Year Member



I managed to find the file and delete it.

I think I'd better stop dabbling in things I don't really know about.

Thanks for all your help anyway.

jtara

4:39 pm on Sep 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Naw, don't stop dabbling. Just do it in a safe place. Create a "sandbox" section of your website that isn't linked-to from anywhere, and do your playing in the sandbox.