anyway, if you can modify the data group format a little bit, i think it will make the irule simpler.
e.g.
[root@ve11a:Active:Changes Pending] config tmsh
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm data-group internal https_rp_list
ltm data-group internal https_rp_list {
records {
services.domain.com/path/ {
data "services-rp.domain.com/path/ services-rp_pool"
}
services.domain.com/path/Enquiry/ {
data "services-rp.domain.com/path/Enquiry/ services-rp_pool"
}
}
type string
}
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm rule myrule
ltm rule myrule {
when HTTP_REQUEST {
if { [class match -- "[HTTP::host][HTTP::uri]" starts_with https_rp_list] } {
set hosturi [class match -name "[HTTP::host][HTTP::uri]" starts_with https_rp_list]
set start [string first "/" $hosturi]
set uri [string range $hosturi $start end]
set matched [class match -value "[HTTP::host][HTTP::uri]" starts_with https_rp_list]
set newhosturi [getfield $matched " " 1]
set newpool [getfield $matched " " 2]
set start [string first "/" $newhosturi]
set newhost [string range $newhosturi 0 [expr {$start - 1}]]
set newuri [string range $newhosturi $start end]
log local0. ""
log local0. "Org Host = [HTTP::host]"
log local0. "Org URI = [HTTP::uri]"
log local0. "New Host = $newhost"
log local0. "New URI = $newuri"
log local0. "HTTP::header replace Host $newhost"
log local0. "HTTP::uri \[string map {$uri $newuri} [HTTP::uri]\]"
log local0. "HTTP::uri [string map {$uri $newuri} [HTTP::uri]]"
log local0. "pool $newpool"
log local0. ""
}
}
}
[root@ve11a:Active:Changes Pending] config tail -f /var/log/ltm
Oct 16 17:50:33 tmm info tmm[23647]: Rule /Common/myrule :
Oct 16 17:50:33 tmm info tmm[23647]: Rule /Common/myrule : Org Host = services.domain.com
Oct 16 17:50:33 tmm info tmm[23647]: Rule /Common/myrule : Org URI = /path/something
Oct 16 17:50:33 tmm info tmm[23647]: Rule /Common/myrule : New Host = services-rp.domain.com
Oct 16 17:50:33 tmm info tmm[23647]: Rule /Common/myrule : New URI = /path/
Oct 16 17:50:33 tmm info tmm[23647]: Rule /Common/myrule : HTTP::header replace Host services-rp.domain.com
Oct 16 17:50:33 tmm info tmm[23647]: Rule /Common/myrule : HTTP::uri [string map {/path/ /path/} /path/something]
Oct 16 17:50:33 tmm info tmm[23647]: Rule /Common/myrule : HTTP::uri /path/something
Oct 16 17:50:33 tmm info tmm[23647]: Rule /Common/myrule : pool services-rp_pool
Oct 16 17:50:33 tmm info tmm[23647]: Rule /Common/myrule :
Oct 16 17:50:36 tmm info tmm[23647]: Rule /Common/myrule :
Oct 16 17:50:36 tmm info tmm[23647]: Rule /Common/myrule : Org Host = services.domain.com
Oct 16 17:50:36 tmm info tmm[23647]: Rule /Common/myrule : Org URI = /path/Enquiry/something
Oct 16 17:50:36 tmm info tmm[23647]: Rule /Common/myrule : New Host = services-rp.domain.com
Oct 16 17:50:36 tmm info tmm[23647]: Rule /Common/myrule : New URI = /path/Enquiry/
Oct 16 17:50:36 tmm info tmm[23647]: Rule /Common/myrule : HTTP::header replace Host services-rp.domain.com
Oct 16 17:50:36 tmm info tmm[23647]: Rule /Common/myrule : HTTP::uri [string map {/path/Enquiry/ /path/Enquiry/} /path/Enquiry/something]
Oct 16 17:50:36 tmm info tmm[23647]: Rule /Common/myrule : HTTP::uri /path/Enquiry/something
Oct 16 17:50:36 tmm info tmm[23647]: Rule /Common/myrule : pool services-rp_pool
Oct 16 17:50:36 tmm info tmm[23647]: Rule /Common/myrule :