Addressing Canonical Issues

Huh… what did you say? Take off your geek hat… just tell me what it means and how to fix it?

Ok. Ok. For our purposes, it simply helps you address duplicate content on your domain.

Canonical issues stem from duplicates of data existing on multiple URLs. For example, url.com and www.url.com and www.url.com/index.html all host the same content.

How to fix Canonical Hostnames on Apache-Based Servers

Create a file using any text editor and save it as “.htaccess.txt”

Next, copy and paste the below information into the file and save.
_________________________________________________
RewriteEngine On
rewritecond %{http_host} ^vonfelten.com
rewriteRule ^(.*) http://www.vonfelten.com/$1 [R=301,L]
_________________________________________________

That’s it… Your ready to test it.

Upload the new .htaccess file to the root directory of your server.
note: Be sure to remove the .txt extension from the file name. On some servers you might have to set the file permissions for the file. You can do this through the interface in most FTP programs. Set it to : chmod 644
Here is another example you might find useful.

How to fix Canonical URLs on Apache-Based Servers

In the example (which is shown on apache.org) we will replace /~user by the canonical /u/user and fix a missing trailing slash for /u/user

_________________________________________________
RewriteRule ^/~([^/]+)/?(.*) /u/$1/$2 [R]
RewriteRule ^/([uge])/([^/]+)$ /$1/$2/ [R]
_________________________________________________
If you need help understanding this in more detail please doesn’t hesitate to contact me or grab more information at apache.org

del.icio.us:Addressing Canonical Issues  digg:Addressing Canonical Issues  spurl:Addressing Canonical Issues  wists:Addressing Canonical Issues  simpy:Addressing Canonical Issues  newsvine:Addressing Canonical Issues  blinklist:Addressing Canonical Issues  furl:Addressing Canonical Issues  reddit:Addressing Canonical Issues  fark:Addressing Canonical Issues  blogmarks:Addressing Canonical Issues  Y!:Addressing Canonical Issues  smarking:Addressing Canonical Issues  magnolia:Addressing Canonical Issues  segnalo:Addressing Canonical Issues

Related Entries

2 Responses to “Addressing Canonical Issues”


  1. 1 Jamie Dec 12th, 2006 at 3:32 am

    Thanks Zach,

    Very handy.

    Do you also have an example for other canonical issues.

    For example using .htaccess to redirect a .com page to it’s .com/index.php complete URL?

    Regards
    Jamie

  2. 2 derek Jun 28th, 2007 at 5:33 am

    Hi!

    Can you help me resolving canonical issues? I already have an .htaccess file, I can make it work following the step you provided above. I edited the existing .htaccess. However whenever I click on my post or link, it gives me a 404 error.

    Here is my original .htaccess:

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

    Thanks

Leave a Reply