I need to rewrite URL to direct request to different backend servers based on query parameter, using a text map of (queryparam servername).
I have tried the RewriteMap, RewriteRule with a prg: type and a perl script. But the query string is not visible in the lookup script.
e.g map file
QS1 Server1 QS2 Server1 QS3 Server3 QS4 Server4 etc.. (about 10K entries -= mapping to about 20 backend servers)
If input URL is http://myrouter.com:8080/a/b/c?query=QS2
then it should be rewritten and sent to http://Server1:9988/a/b/c?query=QS2 (yes with the query string)
http://myrouter.com:8080/a/b/c?query=QS4 sent to http://Server4:9988/a/b/c?query=QS4
My current trials doesnt seem to help.
RewriteEngine on RewriteMap distributeRequests "prg:/export/requestdistributor.pl" RewriteRule ^(.*)$ ${distributeRequests:$1?%{QUERY_STRING}} [P]
I looked up Proxy based on parameter in the URL But that is good for a limited set of lookup entries; not for the 10K query parameters mapping to 10 backend servers I am looking for.
Thanks.