WordPress Canonical URL

This plugin is pretty simple. It is designed to redirect any non-standard single-post URIs to the appropriate permalink.

For example, if you were to go to http://isaacschlueter.com/index.php?p=255&page=2, then you’d see a picture of my fiancée and me by some tulips on the Upper West Side. However, you’d also see an ugly URI in your address bar.

With this plugin, you’d be redirected to /2005/06/breanna/2/ instead.

Here’s what to do if you want this:

  1. Get cannonical-url.php.
  2. Upload it to your /wp-content/plugins/ directory.
  3. Activate it in your Plugins page in the backoffice.

Enjoy :)

New Version: 0.3

Version 0.3 is much improved over the earlier release.

  1. Redirection happens on the page_template and single_template filters instead of page_redirect action, so more information is readily available.
  2. Uses the $wp_query object directly instead of relying on the_post(), which can cause screwey things to happen sometimes.
  3. Better checking for where we are when it’s running, so there’s zero chance of affecting feeds, 404, etc.
  4. Less code!
  5. A helpful 301 message in the response body.
  6. Works on Pages, too!
  7. Unfortunately, cannonical canonical is still spelled wrong. :( My bad. I just realized that today, and it would be way too much effort to go through and correct all the postings in various places, set up a redirection to the new URI, etc. On the plus side, I show up first if you search google for “cannonical”.

This is especially nice if you add “shortcut URIs” to your .htaccess file. Here’s what I use:

RewriteRule ^p(ost)?(id)?/?([0-9]+) index.php?p=$3 [QSA,L]
RewriteRule ^id/?([0-9]+) index.php?p=$1 [QSA,L]
RewriteRule ^t(itle)?/(.*) index.php?name=$2 [QSA,L]

That allows me to type /p305 or /title/sidebar-expando/ and have the link redirect to the proper page. This is handy if you know the post-slug or the ID, and want to quickly type it onto a messageboard or something.

11 Responses to “WordPress Canonical URL”

  1. On July 14th, 2006 at 20:26:53, Elena’s Blog » Using a static home page Said:

    [...] I achieved this by means of the Filosofo Home-Page Control plugin. However, for it to work I had to deactivate another plugin, WordPress Cannonical URL, because using both of them together exceeded the limit of address re-writes.   [...]

  2. On September 12th, 2006 at 05:59:14, Stephane Said:

    Hi,

    Is this working with IIS 6 on win 2003 and WP 2? I tried, but it keeps saying « No input file specified ».

    Thanks for any help,

    Stephane

  3. On October 5th, 2006 at 14:17:05, TEKNOIRE Said:

    [...] WordPress Canonical URL : Fait en sorte que vos billets soient tous accédés avec la bonne URL, sinon effectue une redirection 301 [...]

  4. On January 6th, 2007 at 06:21:43, SEO for feinschmeckere: 301-redirect URL-plugins til WordPress Said:

    [...] Pluginet Permanent Redirect så godt ud, men desværre fik det min side til at gå ned (troede det var servere, men det var i virkeligheden pluginnet). Derfor installerede jeg WordPress Canonical Plugin og det fungerer fint. du kan prøve ved at gå ind på ordpress.dk/?p=3 [...]

  5. On April 13th, 2007 at 16:10:19, Wordpress et moi - liste des plugins utilisés sous Wordpress » Free-Culture.fr Said:

    [...] WordPress Cannonical URL [...]

  6. On April 18th, 2007 at 10:48:27, Project Blogger: Beachamptons Blog Makes a Splash Said:

    [...] Wordpress Cannonical Url - Redirects requests for a single post to the proper permalink location. [...]

  7. On April 27th, 2007 at 07:44:36, » How to avoid duplicate content in search engine promotion Said:

    [...] are Wordpress plug-ins that may help you do this, he [...]

  8. On May 4th, 2007 at 04:33:30, einfach persoenlich Weblog Said:

    Canonical URL – ein Google & Domain-Problem vom Tisch…

    Canonical URL - etwas Hintergrund zu Googles Update Aktivitäten bringen Informationen und Hintergründe zu diesem Begriff. Mit ein paar Handgriffen sind mögliche Probleme zugleich suchmaschinenfreundlich vom Tisch. Wer sich etwas auf die …

  9. On May 18th, 2007 at 11:20:17, Blog Web-Création.ca » Blog Archive » Comment référencer son blog ? Said:

    [...] WordPress Canonical URL : Fait en sorte que vos billets soient tous accédés avec la bonne URL, sinon effectue une redirection 301 [...]

  10. On May 20th, 2007 at 00:47:48, WP Plugins DB » Blog Archive » WordPress Cannonical URL Said:

    [...] Visit [...]

  11. On September 17th, 2007 at 13:32:15, SEO 101 | Duplicate Content avoidance tips Said:

    [...] WordPress Canonical URL Plugin. If you are using WordPress (as I do), install this plugin to take care of duplicate pages that can [...]

Leave a Reply

Comments are moderated like crazy using a variety of plugins. There is a very high likelihood that your comment won't show up right away, especially if you have never commented here before, but it was not deleted.

Please be patient, and do not post your comment more than once. It will show up once it is approved.

You must be logged in to post a comment.