I'm wondering if mod_rewrite is the right tool for this problem. I'd appreciate any suggestions.
I have urls that look like this: /reports/12345.pdf
I have rules that rewrite those urls to /watermark_pdf.cfm?id=12345
which uses some session info to stamp a user's identification on a PDF, saves it in a temp directory, and redirects back to /reports/12345.pdf
I also have a rule that checks whether a previously watermarked file exists in the temp dir, and if it does rewrites the url to that file.
All this is working fine.
Now I have an additional requirement to perform some custom logging whenever a watermarked file is served. I can't add this to the code that does the watermarking, it needs to be "injected" somehow only when the file is served, since we want to keep track of stats like how many times these files are downloaded.
Is there any way that I can use mod_rewrite to "inject" a private request ahead of the actual request? The private request would perform the custom logging, and when it finishes, I would want to rewrite engine to carry on with rewriting the rule.
When I naively tried this by simply not specifying the [L] last flag on the rule that rewrites the URL to do the logging, the logging is performed, but I can't get the rewrite engine to carry on processing with the next rule which is supposed to actually return the content.
Thanks for any help in clarifying if what I'm trying to do here is possible or not.