httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Noah <s...@onastick.net>
Subject Re: [users@httpd] JKMount based on URL query parameters
Date Fri, 06 May 2005 17:58:15 GMT
On Fri, May 06, 2005 at 09:50:49AM -0700, Govindarajulu, Arun wrote:
> Hello,
> 
> I am trying to assign requests to specific tomcat workers based on query
> strings in the URL.
> 
> For example,
> 
>     http://localhost/abc/Team?name=xyz&location=NY should be assigned to
> worker1 and 
>     http://localhost/abc/Team?name=xyz&location=NJ should be assigned to
> worker2
> 
> Is this possible? I tried the following, but it doesn't work.
> 
>     <LocationMatch /abc/Team*location=NY*>
>        JkMount worker1
>     </LocationMatch>
> 
>     <LocationMatch /abc/Team*location=NJ*>
>        JkMount worker2
>     </LocationMatch>

Caveat: I've not tried this; this is all theory

You may be able to mod_rewrite this:

<Location /abc/Team/location/NY>
    JKMount worker1
</Location>

<Location /abc/Team/location/NJ>
    JKMount worker2
</Location>

RewriteEngine on

#
# verify that you have a query string in the request
RewriteCond %{QUERY_STRING} .

#
# snag the value of 'location' and store it in %1;
# optionally use the case insensitive flag ('[NC]')
# if you think 'location' (or it's value) might be
# in mixed-case.
RewriteCond %{QUERY_STRING} location=([^&]+) [NC]

#
# Rewrite
RewriteRule ^/abc/Team /abc/Team/location/%1 [L]


This will internally rewrite the request from a query string type of
request to an all-path type of request; you then set up <Location>
blocks for each area. Things get a bit trickier if you need to make the
'which worker' decision based on more than one element in the query
string, since the order of the query string elements may be different
and mod_rewrite is regex based. Also note that since apache modules are
called in reverse order (bottom to top in the config file), mod_rewrite 
will need to appear *below* mod_jk in your LoadModule list, since the
URL needs to be rewritten before the request is handed off to mod_jk.

In /theory/, this will work. In practice, I can only vouch for the
mod_rewrite code. I'd certainly be interested in knowing the outcome,
though. =)

(note: if any of this doesn't make sense, check out the mod_rewrite docs
at http://httpd.apache.org/docs/mod/mod_rewrite.html)

--n

-- 
"Any system shall not harm your content or, through 
inaction, allow your content to come to harm."
                            - Jeff Raskin

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message