Using Apache and mod_rewrite I can rewrite a complex request to a simple filename, eg:
RewriteRule ^shortcut/(.*)$ /long/way/around/$1
Can this work in reverse? I want a simple request to be rewritten to an unknown file, but I can identify which file should be served by a unique ID number prefixed to it's filename. I want Apache to "guess" using a regular expression which file to serve based on the ID.
For example:
GET /img/29281.jpg
Directory of /img/:
...
29280-filename-here.jpg
29281-other-filename-here.jpg <-- Apache should serve this one
29282-more-files-here.jpg
...
So, a regular expression rewrite could perhaps be:
^(\d+)\.jpg$ --> ^$1\-[a-zA-Z0-9-_]+.jpg$
How to integrate this into Apache (if it's possible)?
Many thanks for any suggestions.
P.S. Renaming all the filenames to the simple ID number isn't an option in this instance.