Tuesday, May 3, 2011

Using Apache and mod_ext_filter, need to dynamically replace values of static file based off of query string.

I've got a situation where I need to alter the contents of a cached file based off of one of the query string arguments passed in. I'd love to use sed to do a simple regular expression replacement of a value based off of said argument but I can't figure that one out. I could use a ruby script to do the replacement for me but can't seem to access the query string for the request within the script. The documents for mod_ext_filter say:

In addition to the standard CGI environment variables, DOCUMENT_URI, DOCUMENT_PATH_INFO, and QUERY_STRING_UNESCAPED will also be set for the program.

Um yeah, can't seem to access those.

Has anybody any experience with this or does anybody have a better solution?

From stackoverflow
  • Using PHP scripting language server function we can able to get the query string values. echo $_SERVER['REQUEST_URI']; And pass the URL arguments as a variable to the file and make it dynamic.

    Refer : PHP.net

  • Doh! Looks like I simply need to access the ENV variable within ruby. Pretty dumb of me.

0 comments:

Post a Comment