How to Switch to a Non-WWW Domain
by Kevin on October 21, 2009
When you start a site, you have a somewhat difficult decision to make. Do you include the “www.” portion of the website or keep it as http://yoursite.com? Both versions will work in most browsers, but it can cause some problems, especially within search engines.
Although search engines and many sites have become smarter regarding these domains, there is certainly still some confusion as to which version you should use. WordPress and other services are set up to include the “www,” so you should be changing this when you set up your site. However, not everyone remembers to do this.
The main way to redirect your entire site (after having it setup to redirect all www domains to non-www domains is using a 301 redirect. You will need to edit your .htaccess file in order for this to work properly. If you do not have access to this, there may be some other way of doing a redirection, perhaps by simply removing the “www” portion of your domain.
A .htaccess (with the period) file can be created by logging into your web server and going to your root folder for your domain. Essentially, the .htaccess file controls any configurations and customizations you make to the default settings of your server.
Moving from WWW to Non-WWW
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
Moving from Non-WWW to WWW
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
This rule is fully search engine supported and won’t cost you when it comes time to re-indexing your site. If you have difficulty deciding which format to use, simply choose one – I prefer the non-www version because it is four characters shorter, but it is up to you which one you use.
If you have any questions, please don’t hesitate to ask.
Leave your comment