Alternatively;
Perl has a data structure for matching regular expressions which is very handy. With two or three lines of code you could take the URL, parse it,look for the word after the last '/', and open the corresponding file.
The thing I don't know about is, if you could make Apache open...