Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating a WordPress site for a client and he mentioned that he would like his own custom URL shortening when sharing to Twitter.

How do I go about setting up one of these? If I had to guess, I would guess that it's a separate domain that redirects to the actual site. If that's the case, then how do I get the URL to redirect to the specific post and not just to the homepage of the site?

share|improve this question

You could try this recipe taken from the chapter on cloning TinuURL in the book Cloning Internet Applications with Ruby -

  • Make a hash of the long url(In this case, if it will be used to redirect to one domain, you could just make a hash of the relative url)
  • Convert it to base 36 - 26 alphabets and 10 digits.
  • Set up a 301 from short/base36(hash) to long domain.

And on the long domain, you can code a controller that sends a request to the short domain to create a short url every time a new page is created.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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