avgjoe.tk – My Own URL Shortening Service


This article is out of date. I now recommend using Bitly for your short URLs. See here for using Bitly with a Freenom (.tk, .cf, .ga, .ml) domain.

Original Post:

Today I got my short URL working for redirecting to my blog posts and predefined links in a Database.

That means, that as of today, all my blog posts have a nice short web address should you want to share it where space is a premium (such as on Twitter or by text)!
You’ll find the short link at the bottom of every post. For example, this post’s address is http://avgjoe.tk/?p=146

Short and sweet, eh?

Techy Bit

I got a .tk domain from dot.tk (there’s no catch, they let you have free domains for nothing! So long as its used by 30 people every 90 days, you’re all good!)

Then I set it to forward to average-joe.info/tk where a copy of my homepage exists with a little extra functionality… script specially targeted at handling my short URL. By looking at window.referrer in JavaScript, it is possible to obtain the URL of the frameset (in the example case http://avgjoe.tk/?p=146). Then, it is possible to extract the bit after the final slash (/) and redirect accordingly. I added a “you are being redirected” message to make sure I comply to the .TK no-redirects rule and for security. It also allows visitors to browse my entire site should they wish!

I decided to display more information than this too: I looked up the forward URL in my blog’s database and retrieved the page title. Just makes it look a little more professional!

I also implemented a method for me to add custom URL forwards. I created a simple database lookup table, so if the URL does not belong to a blog post, it looks it up in my custom redirects. I made http://avgjoe.tk/yt redirect to my YouTube profile.

If you’re interested in more information, please feel free to contact me or post a comment!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s