Shorter Links WordPress plugin

There is a new idea out there that enables a web page to provide an alternative shorter URL for use with services like Twitter. The general idea is that you provide a link tag in the head section and then the client that wants to shorten your URL looks for it and uses it instead of the nice long SEO-optimised version. The first service to use it is RevCanonical at revcanonical.appspot.com. Further details can be found at laughingmeme.org, shiflett.org, benramsey.com and finally Short URL Auto-Discovery.

The link created looks like this:
<link rel="shorturl" href="{shorter version of url}" />

The choice of URL to use for the short link can be configured within Settings->Shorter Links.

The Shorter Links WordPress plugin automatically creates a link element in the section of the post's page with rev="canonical" and rel="alternate shorter" attributes. The URL in the href attribute defaults to the id number of the post in question. A custom field called "Shorter link" is created once a post is saved, so that you can change the shorter link to a more memorable set of characters.

An HTTP headers is also created:
Link: <{$url}>; rel="shorturl"

Download

The Shorter Links plugin is now available from the WordPress Plugin Directory: http://wordpress.org/extend/plugins/shorter-links/

Install

  1. Install directly from within WordPress

or:

  1. Download the zip file and upzip.
  2. Upload shorter_links.php to the /wp-content/plugins/ directory
  3. Activate the plugin through the Plugins menu in WordPress
  4. If you want to set a different Base URL, then change set it from Settings->Shorter Links
  5. To set a custom shorter link, update a post so that the custom field is created and then fill in a unique value in the field.

License

Shorter Links is licensed under the New BSD license.

History

1.3 - 14 April 2009
Add support for setting the base URL. Patch by Dave Marshall.
1.2 - 13 April 2009
Only send the `Link` HTTP header.
1.1 - 13 April 2009
Fixed output of HTTP headers. Patch by Jeff Waugh.
1.0 - 11 April 2009
Initial release

7 Responses to “Shorter Links WordPress plugin”

  1. 1 baron

    Works great, thank you

  2. 2 Jeff Waugh

    The

    if (!headers_sent())
    

    check will never succeed in a wp_head action, and not just because the line preceding it was an echo. ;-)

    I'll send you a patch to fix this up.

  3. 3 Jeff Waugh

    Here you go (sent by email too):

    http://www.gnome.org/~jdub/2009/shorter-links-headers-fix.patch

  4. 4 Rob...

    Jeff,

    Thank you very much :)

    It works on my installation, but I have output buffering enabled, so missed it...

    Regards,

    Rob..

  5. 5 Sam Johnston

    Sorry to be the one to spoil the party, but RevCanonical is a notoriously bad idea. Google's Matt Cutts for one has pointed out the security implications of claiming canonical-ness rather than giving it (as they do), and if you're going to list one inbound link then you really should list them all.

    A *much* better idea is to use rel=shortcut. It fits with "shortcut icon" and actually makes sense ("shortcut" means "a route shorter than the usual one", referring to the canonical URL in this instance). It avoids URI vs URL confusion, space vs underscore confusion, and most importantly REV vs REL confusion (that could result in users' sites vanishing from the Internet).

    Sam

  6. 6 Rev=Canonical and all that Jazz | DaveDevelopment

    [...] also contributed a basic bit of code to Rob Allen's Shorter Links plugin for wordpress, allowing users to specifying a base url, davedevelopment.co.uk isn't [...]

  7. 7 BillSaysThis

    Hi,

    Thanks for the plugin! I've installed to our blog and can see the short URL in the header of single post pages, but the URLs don't work, they result in a Not Found error message.

    Example: http://blog.kachingle.com/2010/03/pardon-this-brief-commercial-interruption-and-3k-post-celebration-by-masterstrack/

    Short URL of same: http://blog.kachingle.com/1232

    Any ideas on how to resolve this?

The views expressed in these comments are not the views of the publisher. However, we believe in the rights of others to express their legitimate views and concerns. Any legitimate complaint emailed to rob@akrabat.com will be seriously considered and the post reviewed as desirable and necessary.

Leave a Reply

Buy now!