I need to create a RewriteRule
to delegate an URL path like /tdg/image.jpg?mode=crop&width=300&height=300
to a local proxy.
The proxy needs the given URL be transformed into the following format.
http://localhost:8888/unsafe/300x300/smart/tdg/image.jpg
I tried first using ProxyPassMatch
apache directive but I can't retrieve the width and height data from the query string.
ProxyRequests On
ProxyPreserveHost On
ProxyPassMatch ^\/(tdg.+\.(?:png|jpeg|jpg|gif))\?mode=crop.+width=(d+)&height=(d+) http://localhost:8888/unsafe/$2x$3/smart/$1
I also tried RewriteRule
RewriteEngine On
RewriteRule ^\/(tdg.+\.(?:png|jpeg|jpg|gif))\?mode=crop.+width=(d+)&height=(d+) http://localhost:8888/unsafe/$2x$3/smart/$1
And in both cases, the result URL for the proxy is http://localhost:8888/unsafe/x/smart/$1
where should be http://localhost:8888/unsafe/300x300/smart/tdg/image.jpg
I have no clue why I can't fetch the width
and height
value from the query string, using group
regex syntax.