Forum Moderators: phranque

Message Too Old, No Replies

LocationMatch regex not working

         

dmwaff

7:19 pm on May 15, 2009 (gmt 0)

10+ Year Member




I must be missing something, I don't see why the regular expression IS working within mod_rewrite but NOT working in <LocationMatch> container.

# Match on Itinerary, Intinerary2, ItineraryB
# [server...]
# [server...]
# [server...]

#--------
# Working
#--------
RewriteRule ^/path/Itinerary[2B]*$ balancer://myCluster/backend/somepage.html [P,QSA,L] lbmethod=bybusyness

#--------
# Not working [server...]
#--------
<LocationMatch ^/path/Itinerary[2B]*>
ProxyPass balancer://myCluster/backend/somepage.html
ProxyPassReverse balancer://myCluster/backend/somepage.html
</LocationMatch>

If I remove the expression [2B]* and specify each of the three matches in individual <Location> or <LocationMatch> container they all work.

Can any explain to me why LocationMatch seem to not eval the expression?

jdMorgan

9:04 pm on May 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is intended by your pattern "[2B]*"? As-is, it will match any string containing any number (including zero) of the characters "2" or uppercase "B" only.

Also, both ProxyPass and ProxyPassReverse require two arguments: A local path to be matched, and a target URL. It appears that you have not specified the local path(s) to be proxied to the balancer in your directives:

ProxyPass documentation [httpd.apache.org]

Jim

dmwaff

10:09 pm on May 15, 2009 (gmt 0)

10+ Year Member



Thanks for the reply

pattern[2B]* I am intending to match:

"pattern" or "pattern2" or "patternB"

ProxyPass and ProxyPassReverse don't require the first argument when inside a <Location> container, it is imply.

jdMorgan

10:45 pm on May 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



With the "*" quantifier, the pattern will accept
pattern
pattern2
patternB
pattern2B
patern2B2B22BB222BBB

Since there is no end-anchor on the pattern, there is no meed to specify "and anything else" past the 2 or the B, so I suspect the pattern you want is just <LocationMatch ^/path/Itinerary[2B]>.

I don't see any documentation about the path being optional in the document I cited. Maybe it's different for your version of Apache.

Jim

dmwaff

2:24 am on May 16, 2009 (gmt 0)

10+ Year Member



Thanks for you input as always!

I'll go back and test some more with the expression. I have tried [2B]*$ too and was thinking that the ?querystring was causing it not to match due to the end of line $ anchor. I will do some more testing but the I need literal "pattern" to match, so the [2B] needs to be optional much like doing a ^/?$ optional trailing slash. Maybe pattern[B2]? will work.

I downloaded and complied a worker mpm version of 2.2.9 from source.

Defining ProxyPass /local [target...] in a location produces the following error. Give it a go, I bet yours does the same. Most of time I do use it outside a <Location> container.

Syntax error on line 35 of /my/path/hidden/conf/extra/dev.conf:
ProxyPass¦ProxyPassMatch can not have a path when defined in a location.

I'll let you know what I find - thanks again.

Caterham

12:34 pm on May 16, 2009 (gmt 0)

10+ Year Member



ProxyPass does not work with a regex (and defining it inside a locationMatch is nothing more than using ProxyPass regEx backend outsitde). Use ProxyPassMatch instead if you need to match against regular expressions.

RewriteRule ^/path/Itinerary[2B]*$ balancer://myCluster/backend/somepage.html [P,QSA,L] lbmethod=bybusyness

Be aware that your lbmethod is lost in such a construct since setting proxy options is not supported by mod_rewrite.

dmwaff

8:23 pm on May 17, 2009 (gmt 0)

10+ Year Member



I understand now and thanks for the insight on the lost proxy balancer option.