Forum Discussion
hooleylist
Nov 20, 2009Cirrostratus
Hi Stéphane,
HTTP::redirect will result in LTM sending the client a 302 redirect to the new location. It sounds like you want to rewrite the URI. You can do this using HTTP::uri:
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: New [HTTP::method request to [HTTP::host][HTTP::uri]"
Check if the URI is /
if {[HTTP::uri] eq "/"} {
log local0. "[IP::client_addr]:[TCP::client_port]: Matched URI check for /"
Check the requested host (set to lower case)
switch [string tolower [HTTP::host]] {
"inter1.alk.com" {
log local0. "[IP::client_addr]:[TCP::client_port]: Matched inter1."
pool Pool_inter1
HTTP::uri "/inter1"
}
"inter2.alk.com" {
log local0. "[IP::client_addr]:[TCP::client_port]: Matched inter2."
pool Pool_inter2
HTTP::uri "/inter2"
}
default {
log local0. "[IP::client_addr]:[TCP::client_port]: No match on Host header value"
}
}
}
}
This example checks for a URI of /, then sets the Host header value to lower case and checks for inter1.alk.com or inter2.alk.com. The corresponding pool is then selected and the URI is rewritten to /inter where is 1 or 2.
You may want to consider handling the default case where someone requests a different host header (or IP address) with a URI of /. That wouldn't be modified by this rule and would be sent to the default pool on the VIP if one is configured.
You can check the /var/log/ltm output from the debug logging. Once done testing either comment out or remove the debug log statements.
Aaron