(This post is meant for those who has (at least) a domain name.)
So, what’s the big deal between using www.domain.com (with www) and domain.com (without www)? You probably didn’t bothered, did you? I guess you didn’t know that it will affect your website or blog’s pagerank too.
According to ekstreme.com, “to search engines, because subdomains are different entities, http://www.domain.com and http://domain.com are two different websites with the same content. This means that they both will be penalized for duplicate content and will rank lower.”
So, have I got your attention now? To www or not to www, it doesn’t really matter. What matters is that you decide between one of them and stick to it. no-www.org recommends websites to drop the www prefix because they claim that it is depreciated and that the “use of the www subdomain is redundant and time consuming to communicate“. Meanwhile, www.yes-www.org argues that it “serves as a gentle reminder that there are other services than the Web on the Internet“.
**********
Method 1: Apache mod_rewrite and 301 redirection:
(source)
To redirect domain.com to www.domain.com:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com [nc]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
To redirect www.domain.com to domain.com:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com [nc]
RewriteRule (.*) http://domain.com/$1 [R=301,L]
If you open up your .htaccess file in a WordPress blog, you’ll see this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
What I’m doing is to redirect tenthofmarch.com to www.tenthofmarch.com. So my version looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^tenthofmarch\.com [nc]
RewriteRule (.*) http://www.tenthofmarch.com/$1 [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Method 2: Using WordPress Plugin
I found 2 WordPress plugins that allow you to redirect either way without the need to tweak the .htaccess file. This is an easier and safer alternative, since you do not touch the .htaccess file. Bare in mind that any mistakes made while tweaking the .htaccess file might cause some problems while accessing your blog.
1. Enforce www. Preference.
I’ve tested this one and it works. This plugin detects the selection you made in the “Blog address (URL)” under Options –> General.
2. Objection-Redirection
Haven’t tried this (lazy) but I think it should work.
**********
Again, it doesn’t matter whether you choose to www or not to www. The important thing is to choose either one. I’ve done a quick check on some blogs that I frequently visit and notice MOST of them have not done this. It is about time you guys decide.