I have a hosted Wordpress blog running on my own domain. I've recently considered trying to build a custom URL shortener (a la bit.ly) that I manage and control using a very short domain. I'm wondering how I can achieve this.

For example:

I want this: http://nerdgap.com/some-made-up-post-here/

To shorten to this: http://g4p.it/23 (where 23 is the Worpress post ID).

Is this possible? How can I go about it?



Try Yourls. I hadn't used it myself but feedback I seen is very positive and it is project by very known developers (Lester Chan and Ozh).


You already get shortlinks of the form ?p=post_id, so http://nerdgap.com/?p=66 points to http://nerdgap.com/great-big-update-plus-giveaway/. You could exploit this by creating a simple redirection from http://g4p.it/{$post_id} to http://nerdgap.com/?p={$post_id}.

You can then integrate this in your editor (the "Get Shortlink" button) and add a <link rel="shortlink"> in your header by hooking into the pre_get_shortlink filter, and returning http://g4p.it/{$post_id}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.