iRule assistance with redirecting to a different pool and URI
Hi Everyone, I am relatively green when it comes to irules and would like some assistance setting one up.
We have been asked to redirect everything under a particular site. Eg: http://oldserver.contoso.com/department/oldsitename/ To be redirected to a new server with a different URI: http://newserver.contoso.com/business/department/newsitename/ However, they want the browser to display the old host name with the new URI: http://oldserver.contoso.com/business/department/newsite/
Since we need to this for over 100 URLs. I thought that the best way to accomplish this would be to use Data Groups. The problem I have is that we would need to redirect clients to a different pool with a modified URI.
The following code works great for redirecting to a different host and different URI using data groups, but I need something that would redirect to a different pool and different URI.
when HTTP_REQUEST {
if { [string tolower [getfield [HTTP::host] ":" 1]] equals "oldserver.contoso.com" } {
set p [URI::path [string tolower [HTTP::uri]] 1 3]
log local0. "Variable p set to: $p"
set m [class match -value $p equals dg_redirect_shpt_paths]
log local0. "Variable m set to: $m"
if { $m ne "" } {
HTTP::respond 301 noserver Location " http://newserver.contoso.com[string map -nocase "$p $m" [HTTP::uri]]"
}
unset -nocomplain p m
}
}
Any advice would be great. Thanks, Chris