Search code examples
regexapachemod-proxyproxypass

ProxyPassMatch regex does not match


Using Apache 2.2.15, I'm trying to set a ProxyPassMatch rule that matches the following request only when the "year" parameter is equal to 2015:

/my-servlet/DownloadPdf?param1=40978659700000&year=2015&param3=testrv%2540rv.com

I know that the following configuration matches my request and works:

ProxyPassMatch /my-servlet/(.*)$ balancer://mycluster

But I want something like this, and it doesn't work:

ProxyPassMatch /my-servlet/(.*year=2015.*)$ balancer://mycluster

I have also tried other regex that match the request, unsucessfully:

ProxyPassMatch /my-servlet/.*year=2015.* balancer://mycluster
ProxyPassMatch /my-servlet/.*year=2015.*$ balancer://mycluster

I don't understand what's wrong with my configuration?


Solution

  • Excerpt from mod_proxy docs

    The path is the name of a local virtual path; url is a partial URL for the remote server and cannot include a query string.
    

    Didn't test it, but a possible workaround:

    RewriteEnginge On
    RewriteCond %{QUERY_STRING} year=2015
    RewriteRule (.*) balancer://mycluster [P]
    

    Let us know, if it did the job and even more so, if it didn't ;)