Short URLs

n: smd_short_url | v: 0.21 | f: /

Documentation for the Textpattern plugin smd_short_url by Stef Dawson follows this short message from our sponsor ;-)

Plugin list button Plugin download button Compressed plugin download button

smd_short_url

Requires TXP 4.2.0.

Allow visitors to use short URLs comprising just site.com/article_ID, which will redirect to the real article.

Install. Activate. Done.

Canonical <link> tag

If you wish to add the canonical <link> tag to your document that defines the article’s short URL for search engines then put <txp:smd_canonical /> somewhere in your <head> section. Remember it must go inside a <txp:if_individual_article> conditional or it will throw an error.

The tag takes one optional attribute: type can either be link (the default) to output the full formatted canonical link tag, or url to output the raw URL so you may use it in your own manner.

Thanks to wet for a large chunk of the code.

Changelog

  • 16 Jun 09 | 0.1 | Initial release
  • 23 Jun 09 | 0.11 | Fixed callback point to play nicely with gbp_permanent_links (thanks pieman/graeme)
  • 19 Jul 09 | 0.2 | Requires TXP 4.2.0 ; changed callback to txp_die and status code to 301 (thanks wet)
  • 17 Sep 09 | 0.21 | Kludge to force HTML redirect if header() fails for whatever reason (thanks the blue dragon)

Source code

If you’d rather dive in and out of functions, you’ll need to step into the view source page.

Legacy software

If, for some inexplicable reason, you need last century's version of a plugin, it can probably be found on the plugin archive page.

Experimental software

If you’re feeling brave, or fancy going bareback, you can test out some of my beta code. It can be found on the plugin beta page.