Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.