:::: MENU ::::
Browsing posts in: URL

How to Create Your Own Custom URL Shortener Service Using YOURLS

I am expecting you might have noticed the short URLs that are being used more and more frequently on Twitter, Facebook, Google and many more places. They look something like this http://goo.gl/maps/lPr5V  and are a way of limiting the size of your website links. There are a handful that are widely used, such as bit.ly, t.co and goo.gl.

I needed to use URL shorteners to tweet my blog posts, and it occurred to me that it would awesome if I could use my own domain klint.co. It is short, descriptive and I own it (as much as you can own a non-physical conceptual digital asset). Furthermore, I want to drive traffic to my site anyway, so why give that traffic to a third party?

I did some initial googling and binging to come up with the tool/library YOURLS. It is a very basic implementation using a database, redirect and some smarts to generate a short unique URL that maps to a normal URL.

And what is even better is that there is a complete WordPress plugin designed to allow you to combine your Twitter account with YOURLS. So far so good.

To set it all up follow these steps:

  1. Download and install YOURLS
  2. Follow the setup instructions
  3. If you are using WordPress install the YOURLS: WordPress to Twitterplugin.
    1. To configure it follow these steps (see what I did there?)
    2. If you have trouble authenticating your Twitter account with the plugin, try and disable all your Twitter related plugins. I had a conflict with one.
    3. You should be able to post to Twitter directly from your posts now.

In addition you can now log into the YOURLS admin panel, which lives at http://yourdomain/YOURLSdir/admin. From here you can create bookmarks to quickly create short URLs for whatever site you are on. This is handy for creating links on the fly which can be used on other sites, to then redirect traffic through your domain.

YOURLS also has the ability to act as an API, so other applications can interact with it and implicitly create short URLs for your domain. You set up a signature token in the YOURLS admin section and use that to authorize 3rd party applications to use YOURLS on your domain. If you are using the Chrome browser, the extension Template can make use of your custom URL shortener.

YOURLS is a great tool, and it is relatively easy to set up and integrate into your various sites, applications and tools. Have you used it? Any problems/caveats? Let me know in the comments below.