Need to generate custome url for bit.ly?

404 Views Asked by At

Hi I am a web application in ROR and shortening url using bit.ly. whenever i create an url using bit.ly i could custom url like http://bit.ly/19Mk8Oj now i want to remove bit.ly and needs to add my own custom url like ferdy.ly/sdf2323 how to do that? when i Google about this and found the following url http://support.bitly.com/knowledgebase/articles/76741-how-do-i-set-up-a-custom-short-domain-. now i have a registered domain for this from http://libyanspider.com/m and need help to integrate the custom domain with my bitly account? and my application is a feedback engine wherein we are charging user for subscription so i choose business account and received a mail from bit.ly that per month i need to pay $1995.. is custom domain name in bit.ly will cost this much?

1

There are 1 best solutions below

0
On

what you want is a url shortener algorithm.

Simple explanation with least efforts:

Have a table that you would store your URLs in for lookup, and the id should be auto-incremented(This is default with AR in Rails), convert the id to base 36 with ruby

6788999.to_s(36) #=> "41ifb" Then you can have a URL as:

foo.com/41ifb

When the request for the shortened URL hits the controller(which you can basically even use bare Routing for) convert the param to an integer:

"41ifb".to_i(36) #=> 6788999

This is a simple basic URL shortener service