301 Redirect Non-WWW to WWW: You Don’t Need It in WordPress

Listen to this Post. Powered by iSpeech.org

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.

 

, ,

8 comments

  1. WOW! I had spend two hours of hacking .htaccess and I alway got an infinite loop. You save me. And I can not believe that it was just to easy. Thank you!

  2. Hi Ryann,

    Can you please tell me exactly where I can find canonical urls in options as I can’t find it – must be missing something here. One of my themes is twenty ten. Thanks

    “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.”

  3. @JT: There is no canonical URLs option field in WordPress actually. It’s all automatically done for you. The redirection www to non-www or vice versa. The canonical URL is determined by the address you specify in the “WordPress Address URL”. Found in Settings -> General -> WordPress Address. So yeah, what you specify in that option field is basically your canonical URL.

    1. Hi Ryann,

      Thanks for the reply. Unfortunately, what you suggest does not seem to work or is it just me.
      For example I have added http://djsinbirmingham.co.uk but this on checking the webconfs redirect tool I get the following “Either djsinbirmingham.co.uk is NOT REDIRECTING to any URL or the redirect is NOT SEARCH ENGINE FRIENDLY”

      Thanks

      1. Hey JT,

        Just checked your website. So your canonical URL is the non-www version (djsinbirmingham.co.uk) of your domain name correct? First test I did was to directly access your website with http://www.djsinbirmingham.co.uk and it redirected to to non-www version of the domain name.

        I then checked your website using the webconf tool http://www.webconfs.com/redirect-check.php and entered the www-version of your URL. Here’s the result below:

        “Found redirect to http://djsinbirmingham.co.uk/. The Redirect is Search Engine Friendly.”

        The webconf tool displays that message you said “Either http://djsinbirmingham.co.uk/ is NOT REDIRECTING to any URL or the redirect is NOT SEARCH ENGINE FRIENDLY” when a domain is not redirecting to anything. but that’s not necessarily an error.

        The webconf tool expects that you enter a URL that will be REDIRECTED, not a canonical url.

        Hope that clears things up.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Anti-spambot Quiz:

Notify me of followup comments via e-mail. You can also subscribe without commenting.