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