Forum Moderators: phranque

Message Too Old, No Replies

Redirect not working in htaccess

Getting Safari can't find server message...

         

grandma genie

4:09 am on Dec 5, 2010 (gmt 0)

10+ Year Member



My webhost originally set up my site with 2 different names: one with and one without the www. I asked him to please make them both with the www, which he has now done. However, now when I find links in Yahoo or Google or wherever with the websiteA.com, they are getting the can't find server message.

Safari can’t open the page “h**p://websiteA.com/animals/mammal1/mammal1.html” because Safari can’t find the server “websiteA.com”.

I thought the htaccess redirect would correct this, but it is not. Is there something wrong with my coding (shown below)?

# Externally redirect certain non-canonical hostnames to canonical hostname, preserving http/https protocol
# FQDN-format www.websiteA.com or with appended port number
RewriteCond %{HTTP_HOST} ^www\.websiteA\.com(\.|\.?:[0-9]+)$ [NC,OR]
# Non-www websiteA.com
RewriteCond %{HTTP_HOST} ^websiteA\.com [NC,OR]
# www- or non-www websiteB.com
RewriteCond %{HTTP_HOST} ^(www\.)?websiteB\.com [NC,OR]
# www- or non-www site2\.hostsite\.com hostname
RewriteCond %{HTTP_HOST} ^(www\.)?site2\.hostsite\.com [NC]
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.*)$ http%2://www.websiteA.com/$1 [R=301,L]

g1smd

5:57 pm on Dec 5, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In order for the code to work, you first need for example.com to "exist" by having a DNS record for it pointing at your server.

It appears your previous instruction to your host to remove this DNS record is the cause of the problem.

grandma genie

4:54 pm on Dec 6, 2010 (gmt 0)

10+ Year Member



Yes, that is right. I asked the host to reinstate the DNS record and now the redirect is working. But I am curious. It seems as though every website has both the www and non-www names, so why does Google consider this duplicate content? That would mean every website existing would be guilty. I'm going to post this in Google forum. Just wanted to thank you, g1smd, for your answer.

g1smd

5:26 pm on Dec 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'll ask you why do you think example.com and www.example.com should be the same?

"www" is just a sub-domain, and so is test, dev, shop, webmail, downloads, and so on. Which one(s) should those be the same as?

The simple answer is that you the webmaster have to send the signal to say they are the same, otherwise they will be assumed to be different.