Question

I am using codeigniter and need to convert a long URL of a website to short URL's like in Google URL shorter...i cant find anything online for this .Please Help

eg: http://www.youtube.com/ to http://goo.gl/fUDP

I am already able to put the long URL's into the database and retrieve it but now i need to convert these URL's to short URL's and display to users

MODEL:

'URL'=> $this->input->post('URL')

VIEW:

URL:<input type="text" name="URL">
Was it helpful?

Solution 2

As People are looking for an answer i would like to post the best comment i found that will help:

URL shorteners aren't too hard. You just need to make a unique ID for each URL (such as fUDP) and add that to the db row (make sure it's indexed). Then when someone goes to the short URL, look up the key and get the full URL. –By @Rocket Hazmat

OTHER TIPS

There is something called as Routing in Codeigniter. Basically, it is a way of customizing the URL according to your needs.

Instead of opting for other tools, I would like you to read the Codeigniter page first:

http://ellislab.com/codeigniter/user-guide/general/routing.html

This will give you an idea on how to shorten the URL. Sometimes, the function names can be a bit messy but you can fix that by Routing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top