A client recently asked me to do a 301 redirect for his WordPress site from http://productivecatholic.com to http://www.productivecatholic.com.
For those of you who are new, the purpose is to have only one URL for a site or a resource in this case http://www.productivecatholic.com. We call this URL the canonical URL. It basically means that www.productivecatholic.com is the “standard” or “authoritative” URL and this is the URL that you want everyone to use. Now why do you want to do this? Well, long story short, this avoids duplicate content issues and it’s good for SEO. For more details, check out the resource link below.
Now, back to my client. So, he asked me to do a 301 redirect for his site so that non-www links will get redirected to it’s “standard” URL. Usually, this would involve installing a WordPress plugin like the Redirection plugin or manually add code to the .htaccess file (my preferred choice).
But, guess what? For this situation, you don’t need to do anything anymore – for sites running on WordPress that is. Since version 2.3, WordPress added a new feature called “Canonical URLs” that will automatically redirect non-www to www and vice versa depending on the specified URL in the Options -> General page. So, if you specify http://example.com as your URL, then WordPress will assume that this is the “authoritative” (canonical) URL and will redirect matching non-canonical links to – like http://www.example.com – if needed. Of course, you could do this the other way around too and specify the www version as “authoritative” like my client wanted and WordPress will do the redirecting for you.
Oh yeah, if you’re wondering, this is a 301 redirect.
The cool thing is, this feature is automatic and you don’t need to do anything to activate it. You no longer need to install a plugin or edit your .htaccess file to do redirects for non-canonical URLs.
To learn more about this feature and how it relates to SEO, read this article by Mark Jaquith.