Shorten your own dang URLs

In my last Project Reclaim post, I talked about using WordPress as a Twitpic-like personal mobile photo service. When the ultimate goal of the photoblog is to send a tweet, it’s almost always necessary to use a URL shortener. But trusting your URL shortening to a free service is a dangerous move. If that service goes out of business, or if they decide to take down the database for some reason or other, the links in those tweets will break. (This problem is delightfully called “linkrot”.)

So, while URL shorteners are sometimes necessary, they’re also an obvious instance for reclaiming your data. Moving to your own URL shortener means that you control the domain, you control the content, you can back up the database however you’d like, etc.

I went with a piece of software called YOURLS. It’s written by Ozh Richard, a WordPress developer, and there’s a slick WP plugin that makes it a great choice for use with my WP photoblog. Here’s a short walkthrough of how I set it up.

Setup

  • Get a domain. Something short is nice, obviously. I just started typing two- and three-letter domains into my domain registrar’s search box (I use Dynadot), which showed me the top-level domains available, until I found one that was easy to look at and remember (http://blo.so). Make sure you do whatever setup your registrar requires to get the domain working – probably as simple as setting the nameservers to your host’s NS addresses.
  • Install YOURLS. The instructions provided at the YOURLS site are pretty concise, but here’s the gist: upload the software to the server, create a new database, copy the sample configuration file to user/config.php, and fill in the configuration file with the proper database info, etc. You can get more YOURLS config info here.
  • Configure an Apache virtual host, if necessary. If your hosting provider doesn’t have cPanel or some other tool that easily lets you point your new short domain to a subdirectory, you’ll need to do it manually by creating a new Apache virtual host file and activating that site. This website has a pretty good explanation. But essentially, just copy the default configuration in sites-available (likely at /etc/apache2/sites-available) and change the info in the VirtualHost section.
  • Install the WordPress plugin. The YOURLS: WordPress to Twitter plugin is easy to install and set up. Once the plugin’s installed, go to Dashboard > Settings > YOURLS and fill in the necessary information. Setting up the Twitter bit is a pain, thanks to Twitter’s requirement that you get a developer’s key, but it’s easy to do. Just follow the on-screen instructions.

At this point, everything should be set up. Send a test post or two to try it out.

Bonus! Use me with Tweetdeck

YOURLS has a REST API that can be used with a bunch of applications. For instance, I’ve configured my TweetDeck installation to do its URL auto-shortening with blo.so. Go to Settings > Services and choose Other from the URL shortener dropdown. Your endpoint will look something like http://blo.so/yourls-api.php?signature=XXXXXXX&action=shorturl&url=%@&format=simple. You’ll have to replace blo.so with your own URL, of course, and the XXXXXXX signature with a custom YOURLS signature password. You can get it from the YOURLS admin screen (http://example.com/admin/tools.php > Secure passwordless API call)

Here’s the great thing. There’s no reason why a couple people can’t share a single YOURLS installation. In fact, I’ll put my money where my mouth is, and start my own URL shortening co-op. I’ll give usernames/passwords to blo.so to the first couple friends who want in. Send an email to boonebgorges at gmail if (1) you are my friend, (2) you want in on blo.so, and (3) you promise to actually use it and break the bit.ly/tinyurl habit.

10 thoughts on “Shorten your own dang URLs

  1. Ron

    I installed YOURLS in January. It’s for our business so we don’t use it for personal links. I’m extremely happy that we invested the money in the domain and the time in setting YOURLS up and getting adjusted to using it.

    1. Boone Gorges Post author

      Ron – Awesome. I know there are lots of people out there using it. I just thought I’d throw up this mini-tutorial to try to convince others.

    1. Boone Gorges Post author

      D’Arcy – Yeah, the overhead and administration bit is a little annoying. But YOURLs, once set up, gives you a pretty sweet little admin panel, where you can create new shortlinks manually, see click stats, and more. Plus, the YOURLS API for hooking into applications like Tweetdeck is a nice inducement, as it makes it more likely that I’ll actually use the shortener in everyday situations.

  2. D'Arcy Norman

    I’m actively trying to minimize the amount of stats I track – do I really need to know metrics on how many people clicked a link? Really? I dropped analytics from all of my sites as well.

  3. Boone Gorges Post author

    D’Arcy – Yeah. I agree that people tend to track too much. And it can introduce a lot of weird psychological overhead when you’re constantly thinking about how many visitors you’ve got, etc. That said, I think it’s perfectly legitimate and healthy to want to know which of the stuff you share is appealing and which is not, and stats can be a way to do that.

    In any case, the API is the real reason for having something more robust like YOURLS. It’s set up so that you can have protected access, which allows (for example) for me to do what I’ve suggested here in the post, which is to give accounts to a few friends without opening it up to the whole world.

  4. Ken Hall

    It has always been a concern of mine, when using a free service for shortening ones URLs, of them going out of business.

    I have not come across the term “linkrot” before and was surprised to find that this is the word that they actually use describe this problem.

    I have heard good things about the software YOURLS, developed by Ozh Richard.

  5. Pingback: Teleogistic / BuddyPress and the YOURLS: WordPress to Twitter plugin

  6. Alan

    Not only might a URL shortener go out of business, a giant asteroid might strike the earth… 😉

    Ironically one of the first shorteners (http://notlong.com/) started in 2002 still works- http://notlong.com/fishtacos was one I used with Brian Lamb in 2006.

    But the integration work you just did with BuddyPress is freakin’ impressive, way to go/code, man.

    A simpler approach for shortening your own WP URLs is the Twitter Friendly Links plugin
    http://kovshenin.com/wordpress/plugins/twitter-friendly-links/

    It just generates them based on your post IDs.

  7. Jack

    Thank you for your information, I was researching various URL shorteners and came across your post, which I am very pleased that I did. I have always been concerned about trusting my site to the free URL shortening services and I like the appropriate name “linkrot” given to when they go out of business. The software called “YOURLs” looks like it will suit my purposes perfectly.

Comments are closed.