Skip to content

Creating a Custom URL Shortener

Having seen a fair few people using their own custom domain for posting links on Twitter and so on (Rob Hawkes with rawk.es, Scott Hanselman with hnsl.mn and various others including tech blogs and news companies with short and sweet names), I thought it was time I grabbed one of my own. I have set it up with bit.ly Pro and thought it might be useful to share my thoughts and experiences.

Finding the Domain

This step is by far the hardest out of the entire process. Finding a domain which looks reasonable, is available and doesn't cost the earth is not an easy thing to do. This is doubly true if you happen to have a name or phrase which doesn't lend itself to any of the TLDs in existence.

In order to help me find my own domain, I turned to the rather nifty Domainr service. Simply feed it a word or phrase, and it'll try and split out some matching domains and even give an indication of whether or not the domain is available to purchase.

Domainr

At this point, something to watch out for is that some TLDs have restrictions on who may purchase them. If there is one you like the look of, be sure to check this early on to avoid having a nasty let down just when you think you are about register it. Domainr gives a Wikipedia link for each TLD it gives you (example: .us domains) and usefully, any restrictions such as needing to be a citizen of a certain country are listed in the sidebar.

The domain I decided to go for in the end was memb.li. I think it is a reasonable compromise between shortness, readability and the fact it existed and was available. Finding a registrar who you trust (there are some seriously sketchy looking sites out there for some extensions) and who is able to provide your chosen TLD isn't always particularly easy. Thankfully, once again Domainr helps out. It provides a column entitled "Register at" which gives several links to some sites which will be able to help out. For my domain I went with iWantMyName, and to be honest was very impressed with the service. The site is slick and easy to use and it made it as easy as possible to register and purchase the domain. The DNS functionality is also top notch and they even provide one-click setup for lots of popular services. It definitely gets a recommendation from me.

URL Shortener Options

In the run up to setting up my custom shortener, I decided to look around for all the possible alternatives. Essentially, it boiled down to one of the following options:

  • Self-host using one of several apps for this purpose (or write another).
  • Use bit.ly Pro, a hosted service and extension to the standard bit.ly URL shortener we all know and love.

There are a few different alternatives for self-hosting. Two pretty decent looking ones are Shaun Inman's Lessn and YOURLS. Both of these are PHP-based, and will require the usuals such as a PHP installation on the server (obviously) and a MySQL database. The advantages to this approach are that you are in full control of your shortener down to the letter, and also have no potential concern that it might go down or change its terms of service unexpectedly. However it also means you have that responsibility too, which may not be attractive to everyone.

Instead of self-hosting, it is possible to use a hosted service which provides support for a custom domain. One such service, as I have pointed out above, is bit.ly Pro. With this approach, it means you are no longer burdened with the responsibility of installing and managing your shortener, but you also relinquish the full control you would otherwise have. One very distinct advantage with this approach however is the ability to have Twitter clients automatically use your custom domain via the bit.ly API.

It should be noted that bit.ly Pro is not the only hosted service which supports using your own domain. Back in 2009, Timo Reitnauer posted a useful article with various options on the iWantMyName blog. This is well worth a look if none of the options I've mentioned suit you.

Bit.ly Pro

For my URL shortener, I decided to go with bit.ly Pro. I decided that the choice was between self-hosting and likely using Lessn or to use bit.ly, and the ease of setting up bit.ly appealed to my lazy side. That and the fact that this is what they do so why not make use of it?

Setting up the domain to use bit.ly Pro was simply a case of telling them what my domain was, and adding the appropriate A record into my domain's DNS. Once this had propagated, I just had to verify it with bit.ly (click a link) and it was ready to go.

Since I'd registered my domain with iWantMyName, the process of setting up the DNS was actually even easier than that. They have the ability to set up your domain to use a variety of services through a convenient one-click system. I simply clicked on the bit.ly logo and the appropriate DNS records were added for me. It literally couldn't be any easier.

Domainr

Once bit.ly was set up, it worked great. Now I can share short links using my domain, and it is pretty seamless. Definitely a positive experience so far, and the fact you are able to view stats about each short link is definitely a plus too.

If there was one thing I would change, it would be the fact there is no way to have a custom landing page. When someone hits one of your short links, it does exactly as you'd expect and redirects through to the appropriate destination. However when someone hits the root URL (in my case, http://memb.li/), it would be nice if it were possible to set up some sort of custom redirect or landing page. For me, I would likely have it redirect through to the home page here at my blog. In reality however, it just goes through to the default bit.ly home page. Definitely a very minor gripe, but it would be nice if this was something which were to be added, as I would imagine it would be easy enough to add—just differentiate based on the Host HTTP header.

End Result

Once everything was set up and verified, it meant that I am now able to share links using my custom shortener, with the added benefit that many Twitter clients will shorten using my domain automatically. All I need to do to make this happen is tell it my bit.ly username and give it my API key.

This means that I have to do nothing differently to what I done previously (i.e. type/paste in a link), and instead of auto-shortening to bit.ly/g9iNT6, I will get memb.li/g9iNT6. In my specific case, I have one extra character compared to using the standard bit.ly domain, but I don't mind that. I'm sure a single character never killed anyone.

Overall, I have found the process of setting up my URL shortener to be quite fun. As I said before, the hardest part by far is deciding on an appropriate domain. The use of iWantMyName is definitely something I would recommend, as is bit.ly Pro despite the minor issues I have with it.

Very Nice, But Why Bother?

A fair question, but I think if you find yourself asking this then perhaps you don't need to bother at all. I think it pretty much boils down to an issue of vanity. I like the idea of having all my links which I want to share shortened to my own domain. That's essentially it, and is probably just the web equivalent of a personalised licence plate (something which incidentally I don't own). Besides the additional branding and potential for customisation (depending on the method you choose), you gain nothing above what all the standard shortening services provide.

It's entirely up to you.