Moe_Jartin
Jan 05, 2009Cirrus
Context Root Masking/URL Rewrite and pool selection
I have an existing iRule that simply selects poolA based on a list of URIs, everything else goes to poolB.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
/contextroot* -
/front* -
/static* -
/css* -
/flash* -
/images* -
/jsimages* -
/xml* -
/xsl* -
/vgn-ext-templating* -
/ -
/script/\* -
/interpret* -
/disabilit* -
/shared* {
pool pool_A
}
default {
pool pool_B
}
}
}
I have now been tasked with masking the "contextroot" so that the browser does not see it but it is still passed to the server. i.e. browser sends request to www.mysite.org/blah/blah/... and I rewrite to /contextroot/blah/blah/... There are several different variables that "blah" could be but, it IS a defined list. So i am thinking of using a stream profile with a class list. here is a first shot at just the context root masking piece, i'll add the rest of the existing rule later.
set OriginalURI HTTP::uri
when HTTP_REQUEST {
if {[matchclass [[string tolower [HTTP::uri]] starts_with $::maskedURIs]} { << STREAM::expression "@$OriginalURI@/contextroot/$OriginalURI@" <<<< Can I use the variable inside the stream expression??
STREAM::enable
pool poolA
}
}
when HTTP_RESPONSE {
if {[[HTTP::status] == 200] and [[HTTP::header value "Content-Type"] contains text]} {
STREAM::expression "@/contextroot@@"
STREAM::enable
}
}
Anyone see anything worng with this or know a better way to do it???