RewriteLock is used with the prg: keyword. RewriteMap can be used with several keywords to use text files ( txt: , a hash of files ( dbm: , randomized text ( rnd: or external matching scripts (this is prg: . In this mode, an external script is launched when apache starts. Then, for every incoming request, when mod-rewrite calls prg: apache sends input to this script and reads the output stream to get the value.
RewriteLock should be used in this case to prevent parallel requests (so parallel inputs to this external process) in order to mix responses on this standard process output. This is a locking mechanism (file, given path, which is a classic token, only one user) to ensure serialization of calls to this external script mapping. IMHO, it should be transparently applied by mod-rewrite when using prg: since I never found a prg case where this locking function is optional .
Edit:
In fact, you can use external prg: without rewriteLock, if randomizing output is not a problem, that is, for this record you can get the answer that was given for another record, for example, in the script some advanced rnd :, your own round-robin service. But if the output should reflect the record, you need this semaphore, which, of course, can slow down the rewriting process.
So, if you use only hashmap or textmap, you do not need to install RewriteLock.
Edit:
You can find useful information about this thread , for example, the fact that the lock file only exists for a few milliseconds when apache calls prg and waits for a response.
Edit: The question is one strange fact:
Original dev used .htaccess file with RewriteMap
This is strange because RewriteMap cannot work with .htaccess.htaccess files - these are configuration entries that are read dynamically, and RewriteMap, as indicated here in the context of the line, can only be set in the main configuration or in VirtualHost configuration. It cannot be in a location, directory, or .htaccess. This will probably never work in .htaccess.
Now @puk asked for an example of using RewriteMap. Well, searching for βRewriteMapβ in a stack overflow will show you some real-world examples:
- here in the question
- here is a list of examples in my answer
- here is another