I'm using ProxyPass for two URLs (A and B below) that both include a question mark and the string 850: -
A: https://frontend.com/850/home?session=25575 -> https://backend.com/850/home?session=25575
B: https://frontend.com/home?session=25575/850 -> https://backend.com/home?session=25575/850
Note that in the above URLs that the 850 string occurs both before and after the question mark.
All advice seems to suggest that the way to deal with a question mark is with a rewrite rule. I would then like to 'lock it down' via LocationMatch (for string 850). Here is my apache code: -
RewriteEngine On
RewriteCond %{QUERY_STRING} .?
RewriteRule ^.?$ [B,NC,R=302,R]
SSLProxyEngine on
ProxyPreserveHost On
<LocationMatch "(.*)850(.*)">
ProxyPass https://backend.com/
ProxyPassReverse https://backend.com/
</LocationMatch>
This works fine for URL A, but not for URL B.
How can I correct this such that it works for both URL A and B?
I've enabled LogLevel alert rewrite:trace6 and I can see in the log files that URL B above is getting translated to https://frontend.com/home? . Hence I cannot match it for the string 850 (already stripped).
850in the path, but inside the query string.850, either in the path or the query string? Then you probably better use an<if>conditional, httpd.apache.org/docs/2.4/mod/core.html#if - either to check if either REQUEST_URI or QUERY_STRING contain850; or by checking againstTHE_REQUEST/to&- is that a typo or intentional?<If "%{THE_REQUEST} =~ m#850#"> Header always set test1 "IT WORKS" RewriteRule ^$ /404.html [R=404,NC,L] </If>but for some reason, it continues to process a locationmatch rule later. I would have thought that the 404 rewrite rule would work as a stop to all further processing.