Reputation: 1839
I'm porting an IIS asapi filter over to linux/apache, and am wondering what the best path to take it. On IIS, this isapi filter intercepts the request, performs a database lookup to find the file the user is requesting, and then rewrites the URL to directly serve that file.
What is the best way to do this on Apache? mod_rewrite doesn't seem to have a facility to interject user code to perform a database lookup, so we can't use that. We can't use the mod_isapi since our DLL is a filter and the module doesn't support that.
Right now, I'm thinking the most straightforward way is to write our own C module, using the mod_rewrite code as a guide. I'd like to avoid that if I can. I also don't want to have to issue an HTTP redirect for each request via a perl/PHP/whatever script since performance will suffer with the redirect.
Suggestions? Can we use Apache handlers or filters to accomplish this?
Upvotes: 0
Views: 753
Reputation: 5277
In mod_rewrite, The MapType "prg" is meant to do exactly this. It lets you use any executable file as your map, all your program has to do is read in strings and output the lookup value.
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
Upvotes: 2