I don't have time at the moment for an in depth answer, but as Jason says it took a lot of planning to get it set up although the final method actually uses url "slugs" much like wordpress rather than id values which was my original intention.
I use a combination of htaccess rules, framework builder and a custom php function which is based on this article .
Again sorry if this is not enough info to get you started but I have deadlines to meet.