Apache rewritemap is a wonderful addon for Apache that can directly connect to a datastore and pull data dynamically. So you don’t have to depend on a scripting language (like PHP, Python) to do the rewriting/redirect for you.
Our use case was to setup “Reverse proxy” to redirect request into different sub domains based on a input URI’s parameter value. Our sub domain data are stored in MySQL tables. This is what we have done to do that,