Custom URL shortening with YOURLS

 

In addition to getting the front-facing part of my website in order before this summer, I’ve been thinking about ways I can control (and keep the data from) more of my web-based infrastructure. Tim Owens has really been leading the way on this front, at least in my little corner of the internet; he recently wrote about dropping Dropbox for ownCloud, and has been actively providing information about and access to various other self-hosted options on Twitter.

I would love to work on bringing my entire infrastructure in-house in the future, and I’m really glad that I’ll have someone to chat with about this stuff when I get there. The reality, though, is I don’t have the time at this moment in my life to break the oh-so-intrenched usage patterns I’ve formed over the last decade of using Gmail and GoogleDocs. I’m a very habit-driven person, and the activation energy for me to completely uproot my routines at this point would be astronomical. That’s exactly what Google and so many other companies (web-based or not) count on; their business model isn’t really about fostering customer loyalty. It’s about taking advantage of users’ inability or unwillingness to change, and carefully balancing the desire for maximum financial benefit with the need to refrain from pissing off the user base so much that they leave altogether.

Even though I don’t have the time or mental space right now for a complete overhaul, I know that having so many of my eggs in one basket is tremendously risky, and so I’m looking for small things I can do to move in the right direction. The low-hanging fruit, as it were. One thing I’ve started doing is downloading all of my email into a local installation of Thunderbird; I have years of correspondence in my Gmail account, and have no confidence in Google’s willingness, or ability, to make sure that content is safely backed up somewhere in case disaster strikes.

I also set up a custom URL shortener for myself, using YOURLS, which is basically a set of PHP scripts you download and install on your own webserver. Because “ryanbrazell.net” is a pretty long domain to use for a URL-shortening service, I wanted to purchased something shorter. I’m terrible at naming things, but I was inspired by my successor at Oberlin, who named at least one of his programming projects after a figure from Greek mythology. This was also partially a strategic move … many Greek names end in “me”, and it’s relatively easy (and inexpensive) to purchase a top-level domain with that ending. (Protip: many of the Roman deity names would be perfect for a .us domain.)

So, I consulted Wikipedia’s listing of Greek mythological creatures, and pretty soon found a name that was both meaningful and available for purchase: euphe.me. (Eupheme was the Greek spirit of good omen and praise; she is also the namesake of a very pretty species of butterfly, which I only learned while doing research for this post.) For right now, this is a private URL shortener that only I can access; going to the homepage of that domain gives a simple HTML page that serves only to hide the underlying structure of the site. To actually access the shortening service requires going to the admin side of the site, and logging in with a username and password.

Originally, the purpose of my setting up a custom URL shortener was to integrate it with Twitter somehow, so that anytime I tweeted a link, my Twitter app would generate a custom url for me and I could track what kind of usage/clicks those links get. I don’t think this is actually possible anymore; Tweetdeck used to allow users to set a custom URL shortening service, but this option is now gone. Version 2.7.1 now offers only two options: Twitter’s t.co shortener, and bit.ly. Bit.ly does provide a service where you can map your domain to their website, use their engine for short url creation, and access your stats. I don’t know about you … but I’d rather keep my distance from anything whose existence depends even slightly on the good graces of the Libyan government, no matter who is in charge of it. And besides, that wouldn’t be in-house.

Since YOURLS to Twitter hasn’t worked out, I’ve been looking for other ways to use this setup. Today, I stumbled upon YOURLS: WordPress to Twitter, a plugin that makes WordPress use the installation of YOURLS you specify to generate short URLs. This replaces the wp.me links that Jetpack automatically generates and sends to Twitter via the Publicize plugin. When this post goes live, that will be the first real test; we’ll all know when the notification tweet goes out whether it’s as easy to install and set up as it seemed. :)

Any thoughts about other sites or ways that a URL shortener could be integrated into a self-hosted infrastructure? Do you know of a Twitter client that can use a third-party URL generator? Let me know in the comments!

css.php