It must be at least a week since I wrote a techo story. Apologies Mum, tonight I’m going to technobabble a little about Uniform Resource Locator (URL) Shortening Services. In almost laymen’s terms a way of mapping a long web-site address name (URL) to a shortened version.
And why do we need or want to do such a “snip-snip-snip” thing I hear you ask?
As we experience a rapid emergence of social networking (eg: Facebook) on the Internet scene; particularly with the recent pervasion of Short Messaging Services (SMS) such as Twitter (2006) the need arose (as well as a whole new service industry) to automatically shorten the length of included URL’s, in line with the limit placed on total characters allowed within the message itself. (In Twitter’s case – 140).
As found in Wikipedia:
URL shortening is a technique on the World Wide Web where a provider makes a web page available under a very short URL in addition to the original address. For example, the URL for this post: http://www.trupela.com/2009/11/26/self-hosted-url-shortening-in-a-nutshell/ has been been shortened to . (
If you click on the shortened URL you will come back to this page)
Currently, web developers tend to pass descriptive attributes in the URL to represent data hierarchies, command structures, transaction paths and session information. This may result in a URL that is aesthetically unpleasant and difficult to remember. Copying a URL that is hundreds of characters long can make the URL garbled. Then a short URL is useful to copy on an e-mail message, a Tweet or a forum post.
Here’s a list of some of the free URL Shortening Services currently doing the rounds:
I have had some exposure to “bit.ly” and “cli.gs” – alongside the WP to Twitter plugin. Although both services are free, mostly reliable and provide some pretty cool statistics – there are several drawbacks when using a 3rd party URL Shortening service:
- Network latency.
- Tracking and analytics of the short URL stored by a 3rd party.
- Companies come (quickly) and go (even quicker). Eg: will “quick.ly” still be around in six months time? Remember no more domain… no more links!
And along came…
YOURLS: Your Own URL Shortener
What is YOURLS?
YOURLS is a small set of PHP scripts that will allow you to run your own URL shortening service (a la TinyURL). You can make it private or public, you can pick custom keyword URLs, and it comes with its own API. There’s also a WordPress plugin available for YOURLS, making integration with your blog a snap: create short URLs and tweet them automagically as you publish blog posts.
- Public (everybody can create short links) or private (your links only).
- Sequential or custom URL keyword.
- Handy bookmarklet to easily shorten and share links.
- Awesome stats: historical click reports, referrers tracking, visitors geo-location.
- Neat AJAXed interface.
- Developer API.
- Friendly installer.
- Assumes that you have a spare Domain name lying around – preferably one with a shortish name. (I happened to have ).
- This Domain will need to point to the directory where YOURLS will be installed. Might require some fiddling with your .htaccess file.
- Check and ensure you meet all the pre-requisites.
- Download and unzip YOURLS software.
- Copy includes/config-sample.php to includes/config.php
- Open includes/config.php with a raw text editor (like Notepad) and fill in the required settings. (see doco).
- Upload the unzipped files to your domain public_html or www folder.
- Create a new database (you can also use an existing one). I did this using MySQL.
- Point your browser to http://yoursite.com/admin/ and configure.
- Ready to rock-n-roll!
Sample YOURLS statistics and graph:
How do I use YOURLS?:
- http://schi.lt/ is installed on the same server as http://www.trupela.com/.
- After publishing a post or a page – I manually create a shortened URL using Post ID (eg: for this post). A very handy bookmark is supplied for this purpose.
- I then Tweet the post (or page) using Firefox add-on Echofon.
- For several existing pages I have created shortened URL’s (eg: .
- It’s interesting having access to fast real-time analytics for the Shortened URL. I have observed that most hits to URL’s embedded within a Tweet occur within the first minute or so of the Tweet getting published.
- Creating Tweets manually versus an automated approach gives me slightly more control over the timing and the wording of the Tweet.