Now how would I do it... Generate and store short url in database together with long url. The tiny urls point to a directory which I guess does not exist - could be handled with a custom "not found" page which looks up long url and redirects.