Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a short URL similar to TinyURL.com

I'm building a new web app that has a requirement to generate an internal short URL to be used in the future for users to easily get back to a specific page which has a very long URL. My initial thoughts are to store a number in a database and output it in a HEXADECIMAL value to keep it shorter than an integer. TinyURL.com seems to use something other than HEXADECIMAL (multiple case letters mixed with numbers). Is there an easy way to generate something similar what TinyURL does?

like image 540
ShawnCBerg Avatar asked Nov 04 '09 00:11

ShawnCBerg


People also ask

How do you design a URL shortening service like TinyURL or bit ly?

System Design goalsClick to the short URL should redirect the user to the original long URL. Shortened link should be as small as possible. Users can create custom url with maximum character limit of 16. Service should collect metrics like most clicked links.

Is TinyURL or Bitly better?

TinyURL is another link shortener tool with a very different look and feel from Bitly. In fact, TinyURL became available before Bitly. This tool is best for users who just need to generate short links on occasion, and don't really have a use for advanced link management or tracking features.


1 Answers

Please, check out this good explanation on subject: Random TinyURL Browser (Updated) .

Important part:

As we have established, there are 62,193,780 possible values for TinyURL's. TinyURL's are generated by a Base 36 hash (36 indicating the number of characters a-z and 0-9, the array of possible values out of which a TinyURL can be constructed), autoincremented by MySQL with an initial value count of zero.

BTW, another SO similar question, through a mathematical view : Creating your own Tinyurl style uid. And here some .NET source code: Base 36 type for .NET (C#)

like image 139
Rubens Farias Avatar answered Sep 19 '22 18:09

Rubens Farias