Redirecting non-www domain: Do You Have Website Schizophrenia?
Are you schizophrenic? Or my favorite name-calling from childhood, two-faced?I’m talking about your website, not you personally. Those personally schizophrenic can just jump to the bottom and begin commenting. Your website can have dual personalities. And if left unchecked it will hurt you. It will cause you acute pain (things won’t work for your visitors) and chronic pain (the search engines will fail to rank you highly over time).I’m referring to your root domain address. You may have bought your domain name, e.g. YourDomainName.com. But look in the address bar, does it show www. yourdomainname.com or yourdomainname.com?What you see up there is important. Answer these two questions, see how you scored and fix your issues, if needed, with my suggestions below.
Website Schizophrenic Test
Question 1: If you type in ‘yourdomainname.com’ into the address bar does it eventually:
- A: display http://www.yourdomainname.com?
- B: display http://yourdomainname.com?
- C: timeout?
Question 2: If you type in ‘www.yourdomainname.com’ into the address bar does it eventually:
- A: display http://www.yourdomainname.com?
- B: display http://yourdomainname.com?
- C: timeout?
Healthy – This is what you want. Personally I prefer my websites exhibit characteristics A and A, rather than Band B. That is, redirecting the non-www to www domains versus the opposite.
Schizo – If that’s you, then you need help and you’re in the right place. We’ll fix you below.
Sick – If one of those addresses doesn’t show anything other than maybe an error, you have a hosting issue that you need to address with your hosting provider (I use Liquid Web) or your webmaster. Take care of that first before you work on your schizophrenic issues.
Dead – Why are you reading this? Your website is dead. You would be happy to be schizo right now, because your website doesn’t exist on the Internet. Go see a doctor and hope for reincarnation.
So You’re A Schizophrenic!
You need to fix this because the search engines are very likely seeing your one website as two because one is preceded by ‘www’ and the other is not. Tell your webmaster immediately!If you're the webmaster, keeping reading.
Apache Web Servers
In the root folder of your website (where your index.html resides) place a new file named ‘.htaccess’. Yes there the first letter of the file is a dot. If you already have one then you can add to it. In your .htaccess file you are going to place the following code. Being sure to replace your domain name with mine.
# -FrontPage-#rewrite markcregan.com to www. markcregan.comRewriteEngine OnRewriteCond %{HTTP_HOST} ^markcregan.com$ [NC]RewriteRule (.*)$ http://www. markcregan.com/$1 [R=301,L]IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
That’s it, now test it out and make sure you’re healthy again.
Microsoft IIS Web Servers
If that’s you then here is my suggested websites. I’ve never worked on an IIS machine as a webmaster
If this helps or you have questions, please let me know. And keep your head on straight.