I'm perfectly happy for the solution to be mime-type based. Maybe we can take the mime-type to *suffix table* from Apache itself to do the translation :- https://svn.apache.org/repos/asf/httpd/httpd/trunk/ docs/conf/mime.types :-P
I used it (implicitly) in a Subversion backed wysi-wiki *ten years ago - * *yeesh!*: https://www.youtube.com/watch?v=WfjK0Pb6IIM (26 seconds of your time: Svn, DAV, Auto-increment, a JavaWeb-app to add on a site experience via Sitemesh, and Mozilla's SeaMonkey editing a page and browsing it).