mydomain.com/show/?id=sf32JFSVANMfaskjfh
Usually I just generate a random string that’s 25 characters long and access my post that way. But in today’s word, short URLs are necessary.
If I want 3-5 letters for the ID…I can’t just generate random characters. It’ll conflict sometime.
What do I do?
if each of your posts have an id already, and it is numeric, you can just encode them using an arbitrary base. think kinda like hex but with larger numbers..
check out this url by leah culver…
http://blog.leahculver.com/2008/06/tiny-urls-based-on-pk.html
for some more ideas. I’ve used this in the past and it works well. In leah’s post it is base 56, so just take your primary key (Integer) and encode it into your new base 56, and you are all set.