Cleaning Up Canonical URLs With Redirects

What the heck is a canonical URL? I didn’t know what a canonical URL was at first either, so don’t worry if you don’t know.

Canonical essentially means “standard” or “authoritative”, so a canonical URL for search engine marketing purposes is the URL you want people to see. Depending on how your web site was programmed or how your tracking URLs are setup for marketing campaign, there may be more than one URL for a particular web page.

The problem most search engine marketers run into deals with domains. Sometimes if a domain is not setup properly, the domain URL ( and the www domain URL ( are considered individual web pages. Since both pages maybe indexed by Google – you could get hit for duplicate content and at the very least you would be splitting your link popularity.

The easiest way to protect your site is to redirect all forms of your domain to one “standard” URL – a canonical URL.

For example to force the use of instead of, I have these lines in my .htaccess file. (This is Apache specific, if you use IIS the lines should be the same using ISAPI filter)

RewriteEngine On
RewriteCond %{HTTP_HOST} ^socialpatterns\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

The first line “RewriteEngine On” tells Apache to enable Mod_rewrite – the engine responsible for manipulating URLs.

The second line “RewriteCond %{HTTP_HOST} ^socialpatterns\.com$ [NC]” looks for when people access The “[NC]” flag makes the test case-insensitive, so it catches URLs like

The third line “RewriteRule ^(.*)$$1 [R=301,L]” redirects to with a 301 redirect.

32 thoughts on “Cleaning Up Canonical URLs With Redirects

  1. So if someone else buys your domain without the www, then they can really jack your link popularity and probably get you banned eventually. Right?

    If so everyone would need to run out and buy that version of their domain and use 301 redirect on it immediately!

  2. Hunter:
    The domain with the www and without are the same domain. Remember that when you purchase a domain you have full access/control of the subdomains. No one can buy a seperate subdomain of your own domain.

  3. Sorry for maybe asking a dumb question, but what would be the same varient for the .htaccess for my .asp hosted sites? Thanks

  4. What do you mean by “should be the same using ISAPI filter” I have some Windows hosting that I would like to use this .htaccess file idea with
    Please advise (2nd request)

  5. Travis,

    The problem lies in how Google views each of these urls. Even though DNS typically points the two urls to the same website, Google will consider the two urls as seperate sites without a 301.

    ISAPI Filter is a mod_rewrite type program you can add onto IIS. If you are using apache, then the rules would be the same – just change the domain to your website.

  6. Pingback: Search Engine Journal » MSN’s Google PageRank of 2 and Canonical URL Problems

  7. Michael
    Is there anyway to just upload an .htaccess file onto your windows hosted domain that will give you the same results as listed above?


  8. Pingback: » A Summary of 301 Redirect Knowledge - Stuntdubl - SEO Consultant

  9. Hello, I put the code in my .htaccess file (editing the url, obviously) and when I try to enter to my site it shows an “500 error”.

    What is happening?

  10. Thank you SOOOOOOOOOO much for the tip. This resolved my problem IMMEDIATELY and will prevent improper search engine crawling. Thank you!!!!

  11. Nothing I try seems to accomplish the renaming. The old name I am having trouble with is permanently forwarded by the old ISP to the new address but for some reason it locks the old name into place.

    The old site needs to become

    How does google etc treat these subdomains of the main

  12. I thinks it’s about time Google resolved this issue on their side of things, not ask all millions of Website owners to change what has been ‘the norm’ since the begining of the internet.

  13. I tried to redirect urls of my website using 301 and everone of them has been giving me an
    error saying that I get the following error message “Redirection limit for
    this URL exceeded. Unable to load the requested page. This may be caused
    by cookies that are blocked”.
    Any ideas?

  14. Pingback: SEO delusions » Another lesson in SEO: Site Availability

  15. Pingback: Matt Cutts: Gadgets, Google, and SEO » Canonicalization update

  16. My question is (not knowing much about apache) is it a simple matter of swapping the two URL parts if is your preference to direct to?

  17. Pingback: Canonicalization update -

  18. Pingback: Canonicalization update ·

  19. I have a domain and a sub-domain, both with the same content. The original domain “” was a static site and we needed to add a shopping cart. I used a sub-domain “” to build the shopping cart site and test it out. Once completed, I did a redirect on the “” site to point to the “” site.

    I am now using the original site “” for testing, of course I still have the redirect. Would this be considered duplicate?

  20. Pingback: einfach persoenlich Weblog

  21. Hi all…

    Relative newbie here learning about all this after just create a web site for my new business venture. I just published my site and Google searches just began displaying some of the pages last night. As I was exploring Webmaster Tools yesterday I discovered in the Settings tab the option to choose a preferred URL or not.

    Have to admit this is a bit overwhelming for a beginner but I was wondering if someone could elaborate a bit more on how to check (and what to look for) with regard to “internal links”. I assume you’re referring to the links on each web page that link to all the other pages on your site? So what is it that we’re supposed to look for?

Comments are closed.